Leaderboard
Popular Content
Showing content with the highest reputation on 07/26/2017 in all areas
-
Have you investigated using a silent installation so that you don't need to automate the install GUIs?1 point
-
how to detect if an other copy from the same script if runing
nacerbaaziz reacted to Jos for a topic
Ok... found the issue. The test in Check() is wrong and should be the below code. It requires brackets around the condition or else the Not doesn't work properly! Func check($exefile) Local $OwnPID = @AutoItPID Local $aProcessList = ProcessList($exefile) If @error Then Return - -1 For $i = 1 To $aProcessList[0][0] If Not ($aProcessList[$i][1] = $OwnPID) Then $rc = ProcessClose($aProcessList[$i][1]) EndIf Next Return 1 EndFunc ;==>check Update that and things should be working when compiled. Jos PS: I do have another life which means I do sleep and work for a big chunk of the day, so just relax and wait till me or somebody has the time and want to spend the effort to help you.1 point -
Example where the buttons get created and the icons get set in a loop: #include <GUIConstantsEx.au3> #include <Array.au3> #include <Math.au3> Global $aButtonLabel = IniReadSection(@ScriptDir & "\test.ini", "BUTTON-LABEL") ; Read section with button labels Global $aButtonState = IniReadSection(@ScriptDir & "\test.ini", "BUTTON-STATE") ; Read section with button states Global $aButtonIcon = IniReadSection(@ScriptDir & "\test.ini", "BUTTON-ICON") ; Read section with button icons ; Make sure all arrays have the same number of rows. Resize if needed Global $iMax = _Max(UBound($aButtonLabel), UBound($aButtonState)) $iMax = _Max($iMax, UBound($aButtonIcon)) ReDim $aButtonLabel[$iMax][2] ReDim $aButtonState[$iMax][2] ReDim $aButtonIcon[$iMax][2] Global $aButtonID[$aButtonLabel[0][0]] ; IDs of the buttons in the GUI. The number of rows in this array is determined by the number of buttons from the ini file Global $iButtonPos = 20 ; Top position of the first button Global $iButtonOffset = 30 ; Offset of the next button ; Create a GUI with various controls. Local $hGUI = GUICreate("Example", 300, 200) ; Create button controls and set state For $i = 1 To $aButtonLabel[0][0] ; Index starts with 1 as all arrays returned by IniRead* functions have the row/column count in row 0 $aButtonID[$i-1] = GUICtrlCreateButton($aButtonLabel[$i][1], 20, $iButtonPos, 85, 25) ; Use an icon for the button GUICtrlSetImage($aButtonID[$i-1], $aButtonIcon[$i][1], 1) ; Set the state of the button If $aButtonState[$i][1] = "Enabled" Then GUICtrlSetState($aButtonID[$i-1], $GUI_ENABLE) Else GUICtrlSetState($aButtonID[$i-1], $GUI_DISABLE) EndIf $iButtonPos = $iButtonPos + $iButtonOffset Next ; Create close button Global $idCloseButton = GUICtrlCreateButton("Close", 210, 170, 85, 25) ; Display the GUI GUISetState(@SW_SHOW, $hGUI) ; Loop until the user exits While 1 $iMsg = GUIGetMsg() ; returns the ID of the button pressed If $iMsg = $GUI_EVENT_CLOSE Or $iMsg = $idCloseButton Then Exit ; Check which button was pressed For $i = 0 To UBound($aButtonID) - 1 If $iMsg = $aButtonID[$i] Then MsgBox(0, "Info", "Button " & $i+1 & " labeled '" & $aButtonLabel[$i+1][1] & "' pressed!") Next WEnd Example of the test.ini: [BUTTON-LABEL] Button1=Button 1 Button2=Button 2 Button3=Button 3 [BUTTON-STATE] Button1=Enabled Button2=Disabled Button3=Enabled [BUTTON-ICON] Button1=C:\temp\alarmGreen.ico Button2=C:\temp\alarmRed.ico Button3=C:\temp\alarmYellow.ico1 point
-
You could set the state of the buttons in a loop and check which button to process in a loop as well. If needed even the creation of the buttons could be done in a loop: #include <GUIConstantsEx.au3> #include <Array.au3> Global $aButtonLabel = IniReadSection(@ScriptDir & "\test.ini", "BUTTON-LABEL") ; Read section with button labels Global $aButtonState = IniReadSection(@ScriptDir & "\test.ini", "BUTTON-STATE") ; Read section with button states Global $aButtonID[3] ; IDs of the buttons in the GUI ; Create a GUI with various controls. Local $hGUI = GUICreate("Example", 300, 200) ; Create a button controls (could be done in a loop as well reading all neded data (label, position from the ini file) $aButtonID[0] = GUICtrlCreateButton($aButtonLabel[1][1], 20, 20, 85, 25) ; Button 1 $aButtonID[1] = GUICtrlCreateButton($aButtonLabel[2][1], 20, 50, 85, 25) ; Button 2 $aButtonID[2] = GUICtrlCreateButton($aButtonLabel[3][1], 20, 80, 85, 25) ; Button 3 ; Set the state of the buttons For $i = 0 To UBound($aButtonID) - 1 If $aButtonState[$i+1][1] = "Enabled" Then GUICtrlSetState($aButtonID[$i], $GUI_ENABLE) Else GUICtrlSetState($aButtonID[$i], $GUI_DISABLE) EndIf Next Local $idCloseButton = GUICtrlCreateButton("Close", 210, 170, 85, 25) ; Display the GUI. GUISetState(@SW_SHOW, $hGUI) ; Loop until the user exits. While 1 $iMsg = GUIGetMsg() ; returns the ID of the button pressed If $iMsg = $GUI_EVENT_CLOSE Or $iMsg = $idCloseButton Then Exit ; Check which button was pressed For $i = 0 To UBound($aButtonID) - 1 If $iMsg = $aButtonID[$i] Then MsgBox(0, "Info", "Button '" & $aButtonLabel[$i+1][1] & "' pressed!") Next WEnd Test.ini:1 point
-
i can, lol. seems a little redundant...1 point
-
EyeBeam CLASS Detection
Xandy reacted to JLogan3o13 for a topic
Have a look at the IUIAutomation thread in the examples forum. I know it can detect a lot more than the native Window Info tool.1 point -
count positions in comma delimited string of numbers
asiawatcher reacted to Gianni for a topic
2 functions _CountBetween and _CountNr useful for the OP purpose, but a bit more generalized Search function _CountBetween will accept the 2 numbers in any order, it will return the distance between them and additional infos in @extent second function _CountNr will return the element located at the wanted offset starting from the passed item Local $sString = "8,5,12,45,67,2,4,50,10,23,hello" _ShowResult(_CountBetween($sString, 5, 8), @error, @extended) _ShowResult(_CountNr($sString, 50, -1), @error, @extended) _ShowResult(_CountNr($sString, 2, 5), @error, @extended) Func _CountBetween($sInput, $sFirst, $sSecond, $sDelim = ",") ; returns the distance between first and second element ; @extent gives you additional infos: ; 0 = First element is on the left. ; 1 = First element is on the right ; 2 = First and second item are same ; ; If an error occurs @error is set to 1 ; and @extend as following: ; 1 = first item not found ; 2 = second item not found ; 3 = both elements not found $sInput = $sDelim & $sInput & $sDelim Local $iExtended = 0, $aFound[2] = [StringInStr($sInput, $sDelim & $sFirst & $sDelim), StringInStr($sInput, $sDelim & $sSecond & $sDelim)] If Not ($aFound[0] And $aFound[1]) Then Return SetError(1, 1 * Not ($aFound[0]) + 2 * Not ($aFound[1]), 0) ; none or only one found Local $0 = Number($aFound[0] >= $aFound[1]), $1 = Number($aFound[0] <= $aFound[1]) ; arrange indexes of found elements StringReplace(StringMid($sInput, $aFound[$0], $aFound[$1] - $aFound[$0] + 1), $sDelim, $sDelim) ; count distance of elements Return SetError(0, $0 + 1 * ($aFound[0] = $aFound[1]), @extended - 1) EndFunc ;==>_CountBetween Func _CountNr($sInput, $sItem, $iNr, $sDelim = ",") ; returns the number located at distance $iNr from passed item ; $iNr can be positive or negative ; @extent 3 all ok or 4 if offset is 0 ; ; if an error occurs @error is set to 1 ; and @extend is 1 or 4 ; 1 = first item not found ; 4 = searc is out of bounds $aInput = StringSplit($sInput, $sDelim, 2) ; $sInput to array For $i = 0 To UBound($aInput) - 1 ; search $sFirst If $aInput[$i] = $sItem Then Local $iNDX = $i + $iNr If $iNDX < 0 Or $iNDX > UBound($aInput) - 1 Then Return SetError(1, 4, "") Return SetError(0, 3 + 1 * ($iNDX = $i), $aInput[$iNDX]) ; @extent 3 all ok or 4 if offset is 0 EndIf Next Return SetError(1, 1, 0) EndFunc ;==>_CountNr Func _ShowResult($result, $error, $extended) ; just to show results Local Static $aErrors[5] = ["", "first element not found", "second element not found", "both elements not found", "searced element is out of bounds"] Local Static $aInfos[5] = ["First element is on the left", "First element is on the right", "First and second are same", "ok", "Distance is 0 returned same number"] If $error Then $sMsg = "Error: " & $aErrors[$extended] Else $sMsg = "Result is " & $result & @CRLF & $aInfos[$extended] EndIf MsgBox("", "err." & $error & " ext." & $extended, $sMsg) EndFunc ;==>_ShowResult1 point -
IE maximize
CalOFduty9000 reacted to Fire for a topic
RunWait("cmd.exe /c " & "start /MIN iexplore.exe http://autoitscript.com/forum/",@ScriptDir,@SW_HIDE) Sleep(2000) WinSetState("[CLASS:IEFrame]", "", @SW_MAXIMIZE)1 point -
Just so you know, the MsgBox() command litterally pauses your script until an action is taken within the MsgBox() itself.1 point