
RC86
Active Members-
Posts
23 -
Joined
-
Last visited
Content Type
Forums
Downloads
Forum Articles
Events
Everything posted by RC86
-
Thanks very much @Zedna and @Melba23 that's awesome! R
-
Apologies, here is an example of the code I am using. I've tried a few of the options for the tab control itself in the Properties, Styles and ExStyles but nothing has done what I'm after. #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <TabConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 305, 212, 192, 124) $Tab1 = GUICtrlCreateTab(8, 8, 289, 193) $TabSheet1 = GUICtrlCreateTabItem("TabSheet1") $Button1 = GUICtrlCreateButton("Go to Tab 2", 32, 56, 75, 25) $TabSheet2 = GUICtrlCreateTabItem("TabSheet2") $Button2 = GUICtrlCreateButton("Go to Tab 1", 33, 57, 75, 25) GUICtrlCreateTabItem("") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 GUICtrlSetState($TabSheet2, $GUI_SHOW) Case $Button2 GUICtrlSetState($TabSheet1, $GUI_SHOW) EndSwitch WEnd
-
Hi, I'd simply like to be able to make the tabs themselves read-only with only the buttons I place on the GUI being able to change them. I am navigating the tabs using the following: GUICtrlSetState($TStep1, $GUI_SHOW) GUICtrlSetData($mode, "Tab1") I've checked through the properties and can't seem to be able to disable the user from selecting any tab they wish manually. Any help would be appreciated. Thanks R
-
OK, noted that sounds good! So I've inserted a bit of code below just as an example...I have 2 exes that I have created. First one is used for creating performance monitor stuff and starting stopping etc. Second one has audit functionality. Every now and then I want to use one executable to call the other one. So all I'm doing is something like a run. Now of course, I have put error logging properly in both executables but I was just wondering if there's a good way to pass this between executables? Also I was concerned if the performance one failed to respond or stop accordingly for any reason. That type of thing really. <PerformanceCounters.au3> - compiled to performance.exe Func _logmanStart() Local $iPID, $sCommand Local $sOutput = "" Dim $configIni, $outputPath $collectorName = "Test" $sCommand = "logman.exe start " & $collectorName $iPID = Run('"' & @ComSpec & '" /c' & $sCommand, "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) While 1 $sOutput = StdoutRead($iPID) ; Exit the loop if the process closes or StdoutRead returns an error. If @error Then ExitLoop Select Case StringInStr($sOutput, "Cannot create a file when that file already exists.") SetError(1,10) Case StringInStr($sOutput, "Data collector set was not found.") SetError(1,11) EndSelect WEnd EndFunc <Audit.au3> - compiled to audit.exe Run("performance.exe" /start)
- 2 replies
-
- exe
- best practice
-
(and 1 more)
Tagged with:
-
Afternoon! Just a quick one as this has dawned on me recently when creating a little program. When calling an executable I've created like Run(otherapp.exe) from within my executable is there a best practice to ensure things have gone smoothly? So for example, should I monitor the PID to ensure it runs and closes within an acceptable timeframe? Or within my other executable should I do EXITs in a certain way after functions and return codes etc? Could be a silly question but thought I'd ask.
- 2 replies
-
- exe
- best practice
-
(and 1 more)
Tagged with:
-
Gotcha, very handy! THanks for the help!
-
Awesome! Never knew you could do that. I completely understand your final remark about checking the ObjGet worked first, that should be a simple change for my code, but as for the ObjEvent("AutoIt.Error","_COMErrFunc") I'm not quite there yet! Does that mean I can still keep my SetErrors and all of that functionality (where applicable) within my code and this extra bit will catch those critical AutoIT errors that prevent it running then? I'll have to dig through the related help file and get my head around it! Thanks very much!
-
Hi all, Bit of a fun one with querying WMI objects and setting errors within a function. Below is example code that I've used from JSThePatriot previous UDFs but the example would apply to many other scenarios. Basically the SetError should be called if $colItems is not an object as a result of the WMI query. This is then used to create a corresponding error message. I've tried disabling WMIC thus forcing it to not be an object, but rather than catching the error and telling me about it, the code simply fails therefore surely making the purpose of the logging useless?? I've experienced this before but in other languages such as java i would use a try catch etc and get around this....any suggestions for its use in AutoIT? Thanks #region Header #comments-start Title: Computer Information Automation UDF Library for AutoIt3 - EXAMPLES Filename: CompInfoExamples.au3 Description: Examples using the UDF's from CompInfo.au3 Author: Jarvis J. Stubblefield (JSThePatriot) http://www.vortexrevolutions.com/ Version: 00.03.08 Last Update: 11.09.06 Requirements: AutoIt v3.2 +, Developed/Tested on WindowsXP Pro Service Pack 2 Notes: Errors associated with incorrect objects will be common user errors. AutoIt beta 3.1.1.63 has added an ObjName() function that will be used to trap and report most of these errors. Special thanks to Firestorm (Testing, Use), Koala (Testing, Bug Fix), and everyone else that has helped in the creation of this Example File. #comments-end #endregion Header #region Global Variables and Constants If Not(IsDeclared("$cI_CompName")) Then Global $cI_CompName = @ComputerName EndIf Global Const $cI_VersionInfo = "00.03.08" Global Const $cI_aName = 0, _ $cI_aDesc = 4 Global $wbemFlagReturnImmediately = 0x10, _ ;DO NOT CHANGE $wbemFlagForwardOnly = 0x20 ;DO NOT CHANGE Global $ERR_NO_INFO = "Array contains no information", _ $ERR_NOT_OBJ = "$colItems isnt an object" #endregion Global Variables and Constants #Region Boot Configuration Dim $BootConfig _ComputerGetBootConfig($BootConfig) If @error Then $error = @error $extended = @extended Switch $extended Case 1 _ErrorMsg($ERR_NO_INFO) Case 2 _ErrorMsg($ERR_NOT_OBJ) EndSwitch EndIf For $i = 1 To $BootConfig[0][0] Step 1 MsgBox(0, "Test _ComputerGetBootConfig", "Name: " & $BootConfig[$i][0] & @CRLF & _ "Boot Directory: " & $BootConfig[$i][1] & @CRLF & _ "Configuration Path: " & $BootConfig[$i][2] & @CRLF & _ "Last Drive: " & $BootConfig[$i][3] & @CRLF & _ "Description: " & $BootConfig[$i][4] & @CRLF & _ "Scratch Directory: " & $BootConfig[$i][5] & @CRLF & _ "Setting ID: " & $BootConfig[$i][6] & @CRLF & _ "Temp Directory: " & $BootConfig[$i][7]) Next #endregion Boot Configuration #region ---- Internal Functions Func _ErrorMsg($message, $time = 0) MsgBox(48 + 262144, "Error!", $message, $time) ConsoleWrite("Error!" & $message & $time & @CRLF) EndFunc #endregion Internal Functions Func _ComputerGetBootConfig(ByRef $aBootConfigInfo) Local $colItems, $objWMIService, $objItem Dim $aBootConfigInfo[1][8], $i = 1 $objWMIService = ObjGet("winmgmts:\\" & $cI_Compname & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_BootConfiguration", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) Then For $objItem In $colItems ReDim $aBootConfigInfo[UBound($aBootConfigInfo) + 1][8] $aBootConfigInfo[$i][0] = $objItem.Name $aBootConfigInfo[$i][1] = $objItem.BootDirectory $aBootConfigInfo[$i][2] = $objItem.ConfigurationPath $aBootConfigInfo[$i][3] = $objItem.LastDrive $aBootConfigInfo[$i][4] = $objItem.Description $aBootConfigInfo[$i][5] = $objItem.ScratchDirectory $aBootConfigInfo[$i][6] = $objItem.SettingID $aBootConfigInfo[$i][7] = $objItem.TempDirectory $i += 1 Next $aBootConfigInfo[0][0] = UBound($aBootConfigInfo) - 1 If $aBootConfigInfo[0][0] < 1 Then SetError(1, 1, 0) EndIf Else SetError(1, 2, 0) EndIf EndFunc ;_ComputerGetBootConfig
-
Thanks very much! Greatly appreciated.
-
Morning! I've searched for a definitive answer on the forums on this but can't find one so here goes. I need admin for one of my functions so I'm using #RequireAdmin. I then noticed that regardless of that function being used or admin actually being required, the program pops up and requires admin all of the time. Is this the way it's designed and is there a way around it so that I can launch my program as normal until admin is required, then and only then prompt the user to run the program as admin? The only solution I could think of is to produce 2 executables and do something like: $adminrequired = 1 If($adminrequired = 1) Then Run(Run first executable which includes #RequireAdmin) Else Run(Run second identical executable without #RequireAdmin) EndIf Obviously I'd rather keep to making a single executable rather than having 2 or 3! Thanks
-
Please delete this post. Apologies for any inconvenience caused I answered my own problem.
-
Awesome! That was a lot easier than expected thank you very much!
-
Afternoon, I could very well be doing this wrong so feel free to totally advise otherwise - I'm wanting to use a GUI to first display a key from within an INI file, then secondly change the INI file by using a FileSelectFolder command but then I want to see the GUI change to reflect the change I've just made. #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 615, 437, 192, 124) $Input1 = GUICtrlCreateInput(Iniread(@WorkingDir & "\test.ini","Path","FilePath",""), 64, 80, 121, 21) $Button1 = GUICtrlCreateButton("Change", 200, 80, 75, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $selectedFolder = FileSelectFolder("Select Log Path Directory",@WorkingDir,0) If NOT $selectedFolder = "" Then $newLogPath = IniWrite(@WorkingDir & "\test.ini","Path","FilePath",$selectedFolder) EndIf EndSwitch WEnd So 2 part question really: (1) Should I be using GUICtrlCreateInput to display my INI read from within the GUI? (2) How can I refresh the GUI to update that to read the new information I've just written to the GUI? Thanks!
-
Ha thanks buddy - have an awesome afternoon!
-
HA!!! I'm so sorry I understand what you meant by your previous comment - I can't believe I managed to be that stupid - I'm going to take myself for a bit of fresh air now! Thank you!!!
-
Sorry I'm probably bad at explaining - I was trying to use the array contained in element $memoryInfo[1] and assign it a new array so i could then access its individual elements. But i was showing that this does not work using those lines - so is there another way it can be done?
-
Yea I've edited that in my original post thanks. My issue is lines 8-12. You'll notice they are blank. I'm trying to access elements from an array that have been returned within an array. eg. So by running _getMemoryInfo() function the return value is an array and im assigning it to $memoryInfo. That means $memoryInfo is an array then with 2 elements [0] is a string [1] is an array. So u can make [1] show in its entirety (using _ArrayDisplay), but how can you access the individual elements of the array now stored within $memoryInfo[1].
-
Apologies, I've edited the code now so it runs from copy paste. No sorry - the issue I'm having is you'll notice the final message box/array display will show blank. I'd like to be able to access the elements from the returned array, but as that has been returned within an array, is that even possible?
-
Afternoon! I have a requirement to return both a string and an array from a function so as a result I put them both into an array and returned that. I can access them in their entirety after returning them but then I can't seem to access the array elements after this. Should I be able to or is there a prettier way? #include <Array.au3> ;Memory info returned as a string and an array $memoryInfo = _getMemoryInfo() msgbox(0,"Memory Info",$memoryInfo[0]) _ArrayDisplay($memoryInfo[1],"Memory as an Array") Local $newArray[7] $memoryInfo[1] = $newArray msgbox(0,"Test element",$newArray[0]) _ArrayDisplay($newArray) Func _getMemoryInfo() Local $newArray[7] Local $array = MemGetStats() $newArray[0] = $array[0] ;% of memory in use $newArray[1] = Round($array[1]/1024 * 0.001,2) ;Total physical RAM $newArray[2] = Round($array[2]/1024 * 0.001,2) ;Availaible physical RAM $newArray[3] = Round($array[3]/1024 * 0.001,2) ;Total pagefile $newArray[4] = Round($array[4]/1024 * 0.001,2) ;Available pagefile $newArray[5] = Round($array[5]/1024 * 0.001,2) ;Total virtual $newArray[6] = Round($array[6]/1024 * 0.001,2) ;Available virtual $memoryUsage = $newArray[1] - $newarray[2] $pagefileUsage = $newArray[3] - $newarray[4] ;Output/Return Local $returnArray[2] $returnArray[0] = "Memory: " & $memoryUsage & " GB/" & $newArray[1] & " GB " & @CRLF & "Pagefile: " & $pagefileUsage & " GB/" & $newArray[3] & " GB " $returnArray[1] = $newArray return $returnArray EndFunc A bit messy but hopefully it's understandable what I'm trying to achieve. Thanks!
-
OK thanks, I'll give it a go - i've read that I can't use $wbemFlagForwardOnly if I want to do anything with the object like count. THanks for your help!
-
Thanks, so you'd get it into a string then from there into an array? I did try initially to get each of the lines into an array but it wasn't particularly dynamic and meant a lot of editing. Ideally I'd like to find out how to query the object like with a count of the items in that object or something but I can't find any way of querying it.
-
Hi! First post - go easy! I'm using the Scriptomatic tool that SvenP created based on the Microsoft tool and I'm just a bit unsure about how to use the output as I wish. Func _getMemory() $logSection = "Memory" $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $strComputer = "localhost" $Output = "" $Output = $Output & "Computer: " & $strComputer & @CRLF $Output = $Output & "==========================================" & @CRLF $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\ROOT\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_PerfFormattedData_PerfOS_Memory", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) Then For $objItem In $colItems $Output = $Output & "AvailableBytes: " & $objItem.AvailableBytes & @CRLF $Output = $Output & "AvailableKBytes: " & $objItem.AvailableKBytes & @CRLF $Output = $Output & "AvailableMBytes: " & $objItem.AvailableMBytes & @CRLF $Output = $Output & "CacheBytes: " & $objItem.CacheBytes & @CRLF $Output = $Output & "CacheBytesPeak: " & $objItem.CacheBytesPeak & @CRLF $Output = $Output & "CacheFaultsPersec: " & $objItem.CacheFaultsPersec & @CRLF $Output = $Output & "Caption: " & $objItem.Caption & @CRLF $Output = $Output & "CommitLimit: " & $objItem.CommitLimit & @CRLF $Output = $Output & "CommittedBytes: " & $objItem.CommittedBytes & @CRLF $Output = $Output & "DemandZeroFaultsPersec: " & $objItem.DemandZeroFaultsPersec & @CRLF $Output = $Output & "Description: " & $objItem.Description & @CRLF $Output = $Output & "FreeAndZeroPageListBytes: " & $objItem.FreeAndZeroPageListBytes & @CRLF $Output = $Output & "FreeSystemPageTableEntries: " & $objItem.FreeSystemPageTableEntries & @CRLF $Output = $Output & "Frequency_Object: " & $objItem.Frequency_Object & @CRLF $Output = $Output & "Frequency_PerfTime: " & $objItem.Frequency_PerfTime & @CRLF $Output = $Output & "Frequency_Sys100NS: " & $objItem.Frequency_Sys100NS & @CRLF $Output = $Output & "LongTermAverageStandbyCacheLifetimes: " & $objItem.LongTermAverageStandbyCacheLifetimes & @CRLF $Output = $Output & "ModifiedPageListBytes: " & $objItem.ModifiedPageListBytes & @CRLF $Output = $Output & "Name: " & $objItem.Name & @CRLF $Output = $Output & "PageFaultsPersec: " & $objItem.PageFaultsPersec & @CRLF $Output = $Output & "PageReadsPersec: " & $objItem.PageReadsPersec & @CRLF $Output = $Output & "PagesInputPersec: " & $objItem.PagesInputPersec & @CRLF $Output = $Output & "PagesOutputPersec: " & $objItem.PagesOutputPersec & @CRLF $Output = $Output & "PagesPersec: " & $objItem.PagesPersec & @CRLF $Output = $Output & "PageWritesPersec: " & $objItem.PageWritesPersec & @CRLF $Output = $Output & "PercentCommittedBytesInUse: " & $objItem.PercentCommittedBytesInUse & @CRLF $Output = $Output & "PoolNonpagedAllocs: " & $objItem.PoolNonpagedAllocs & @CRLF $Output = $Output & "PoolNonpagedBytes: " & $objItem.PoolNonpagedBytes & @CRLF $Output = $Output & "PoolPagedAllocs: " & $objItem.PoolPagedAllocs & @CRLF $Output = $Output & "PoolPagedBytes: " & $objItem.PoolPagedBytes & @CRLF $Output = $Output & "PoolPagedResidentBytes: " & $objItem.PoolPagedResidentBytes & @CRLF $Output = $Output & "StandbyCacheCoreBytes: " & $objItem.StandbyCacheCoreBytes & @CRLF $Output = $Output & "StandbyCacheNormalPriorityBytes: " & $objItem.StandbyCacheNormalPriorityBytes & @CRLF $Output = $Output & "StandbyCacheReserveBytes: " & $objItem.StandbyCacheReserveBytes & @CRLF $Output = $Output & "SystemCacheResidentBytes: " & $objItem.SystemCacheResidentBytes & @CRLF $Output = $Output & "SystemCodeResidentBytes: " & $objItem.SystemCodeResidentBytes & @CRLF $Output = $Output & "SystemCodeTotalBytes: " & $objItem.SystemCodeTotalBytes & @CRLF $Output = $Output & "SystemDriverResidentBytes: " & $objItem.SystemDriverResidentBytes & @CRLF $Output = $Output & "SystemDriverTotalBytes: " & $objItem.SystemDriverTotalBytes & @CRLF $Output = $Output & "Timestamp_Object: " & $objItem.Timestamp_Object & @CRLF $Output = $Output & "Timestamp_PerfTime: " & $objItem.Timestamp_PerfTime & @CRLF $Output = $Output & "Timestamp_Sys100NS: " & $objItem.Timestamp_Sys100NS & @CRLF $Output = $Output & "TransitionFaultsPersec: " & $objItem.TransitionFaultsPersec & @CRLF $Output = $Output & "TransitionPagesRePurposedPersec: " & $objItem.TransitionPagesRePurposedPersec & @CRLF $Output = $Output & "WriteCopiesPersec: " & $objItem.WriteCopiesPersec & @CRLF ;if Msgbox(1,"WMI Output",$Output) = 2 then ExitLoop Next _Log($Output) ;_writeCSV($Output) $Output = "" Else MsgBox(0, "WMI Output", "No WMI Objects Found for class: " & "Win32_PerfFormattedData_PerfOS_Memory") EndIf I'm querying WMI for some performance data and as you can see I can write this info to a log file just fine as a string, but ideally I'd like to be able to see this info in an array. If $colItems is the array how can I see this, I've tried using _ArrayDisplay but no luck. I think I'm missing something or not quite understanding too well. Thanks!