-
Recently Browsing 0 members
No registered users viewing this page.
-
Similar Content
-
By plankton
Hi I want it to search for a specific color in certain area then excute the loop which presses ESC button and stop the loop when the color no longer present in that specific area. Here is the example of my code. But it doesnt stop when color is disappeared.
Pixelsearch(511, 455, 678, 501, 0xFFFFFF)
If Not @Error Then
While 1
Sleep(1000)
Send("{ESC}")
Pixelsearch(511, 455, 678, 501, 0xFFFFFF)
If @Error Then Exitloop
-
By crushyna
Hi everyone!
I'm developing small testing tool for new software in my company.
Tool itself is working correctly (it follows scripted test commands one by one), but I'm trying to develop an error checking function.
Mechanics are simple: every time software (external) shows specific error (via window class), program asks for next step. Continue, or abort test (and return to main GUI)?
The error check function is switched on/off via Checkbox in GUI.
Here are some code fragments:
Checkbox:
Global $idCheckbox1 = GUICtrlCreateCheckbox("Enable TP.net error handling", 352, 40, 249, 17) GUICtrlSetFont(-1, 12, 400, 0, "Calibri") GUICtrlSetColor(-1, 0x000000)
Checkbox switch:
GUISetState(@SW_SHOW) Local $Choosen While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idCheckbox1 If _IsChecked($idCheckbox1) Then $cSwitch1 = 1 Else $cSwitch1 = 0 EndIf Case $idAddTest (and so on...)
Function call:
(alot of ElseIf commands...) ElseIf $aItem = $idOperatorIn Then WywolanieOkna() WinActivate($hFSO) ControlClick($hFSO, "", "[NAME:lblCashierNumber]") Sleep($Sleep_05) Send("0000019{Enter}19{Enter 2}") Sleep($Sleep_75) EndIf #EndRegion ### START ELSEIF ARMY ### Next If $cSwitch1 = 1 Then MsgBox( 0, "Error check!", "Error check ON!") /// just for testing purposes CheckError() Else Return EndIf EndSwitch WEnd
Classic _IsChecked function:
Func _IsChecked($idControlID) Return BitAND(GUICtrlRead($idControlID), $GUI_CHECKED) = $GUI_CHECKED EndFunc ;==>_IsChecked
And Checkerror() function itself:
Func CheckError() Local $Answer If ControlCommand($hMsgPanel, "", "[NAME:panelMsgBox]", "IsEnabled", "") Then ;~ Sleep($Sleep_05) $Answer = MsgBox(52, "Error!", "An error occured! Continue testing?") ;~ Sleep($Sleep_05) Switch $Answer Case 6 MsgBox(0, "Error!", "Test will now continue.", 3) Send("{Enter}") WinActivate($hWnd) Return Case 7 MsgBox(64, "Error!", "Test cancelled.", 5) $ElseIfArmyOff = 1 ControlClick($hMsgPanel, "", "[NAME:cmdOK]") WinActivate($AppName) #cs MsgBox( 0, "test1", $idTSList) Local $idTSListCopy For $i = 0 to _GUICtrlListView_GetItemCount($idTSList) - 1\ #ce $idTSListCopy = _GUICtrlListView_GetItemTextString($idTestCaseList, $LoopCount) ExitLoop EndSwitch EndIf Return 1 EndFunc ;==>CheckError
Problem is: i can't make this function (CheckError() ) return to main gui state, that means: break the If/ElseIf loop.
The switch is working correctly (MsgBox on error shows only when it's activated).
Checkerror() function works correctly - recognizes the error, stops script until decision is made. But it doesn't terminate If/ElseIf loop.
Any help appreciated!
-
By souldjer777
Good Morning AutoIT Gurus and Masters
Slightly complicated array here... and infinite loop that I'm trying to output to a file after the values are matched up; then anything that doesn't match is deleted from the array and finally written to a file...
This guy does an infinite loop... and I'm not sure why... I tried to put in message boxes - but there are 20K records so I couldn't click through that many. LOL.
#RequireAdmin #include <array.au3> #include <file.au3> #include <Excel.au3> #include <MsgBoxConstants.au3> Global $WXYZArray01, $array01, $ProgramTitle, $sleeptime, $k01 $ProgramTitle = "Testing 1 2 3" $sleeptime = 1000 _FileReadToArray(@ScriptDir & "\" & "testing_output_csv_unique_values.csv", $array01, "", ",") ;_ArrayDisplay ($array01, "Array01") $aUniqueHostname = _ArrayUnique ($array01, 1) ;_ArrayDisplay ($aUniqueHostname, "UniqueHostname ") For $i01 = Ubound($aUniqueHostname) - 1 to 0 Step - 1 For $j01 = Ubound($array01) - 1 to 0 Step - 1 If $array01[$j01][1] == $aUniqueHostname[$i01] and StringRegExp($array01[$j01][5], "MY_VALUE") then MsgBox(0, "Computer and MY_VALUE", $aUniqueHostname[$i01] & " : " & $array01[$j01][5]) $FileName01 = @ScriptDir & "\" & $array01[$j01][3] & "_" & $aUniqueHostname[$i01] & "_" & $array01[$j01][2] & ".csv" MsgBox(0, "File Name", $FileName01) $WXYZArray01 = $array01 _ArrayDisplay ($WXYZArray01, "WXYZ Array") SplashTextOn($ProgramTitle, 'Generic - Please wait for loop to complete...', 400, 40, -1, -1, 2, "", 10) Sleep ($sleeptime) For $k01 = 0 To Ubound($WXYZArray01) - 1 ; MsgBox (0, "In the WXYZ loop", $WXYZArray01[$k01][1] & " : " & $aUniqueHostname[$i01]) If $WXYZArray01[$k01][1] <> $aUniqueHostname[$i01] Then ;MsgBox (0, "In the WXYZ loop - Delete", $WXYZArray01[$k01][1] & " : " & $aUniqueHostname[$i01]) _ArrayDelete($WXYZArray01, $k01) ;_ArrayDisplay ($WXYZArray01) $k01 -= 1 EndIf If $k01 = UBound($WXYZArray01) - 1 Then ExitLoop Next SplashOff() MsgBox (0, "Out of the WXYZ loop", "Out of the WXYZ loop - File Write From Array") _FileWriteFromArray($FileName01, $WXYZArray01, 1) ExitLoop EndIf Next Next I'm hoping someone here can tell me why at a glance... I'm a little burned out to see the answer... feeling toasty LOL
Thank you everyone for your help!
-
By ale1981
I might be doing this wrong but this seems to crash the GUI, what I want is to click the button, select something from the list view with a double click which populates the input box and delete's the GUI?
#include <GUIConstantsEx.au3> #include <GUIListView.au3> #include <Misc.au3> #include <WindowsConstants.au3> $hGUI = GUICreate("Test", 400, 400) $btn = GUICtrlCreateButton( "", 150, 50, 75, 20 ) $cInput = GUICtrlCreateInput( "", 10, 50, 100, 20 ) GUISetState() GUIRegisterMsg( $WM_NOTIFY, "WM_NOTIFY" ) Global $idListview While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $btn listpackers() EndSwitch WEnd Func listPackers() Global $packersGUI = GUICreate( "Packers List", 300, 300, -1, -1, $WS_SYSMENU ) $idListview = GUICtrlCreateListView( "", 2, 2, 294, 268 ) GUISetState( @SW_SHOW ) Local $packerList[2][2] = [[1, "Name1"],[2, "Name2"]] ; Add columns _GUICtrlListView_AddColumn( $idListview, "Packer ID", 75 ) _GUICtrlListView_AddColumn( $idListview, "Packer Name", 150 ) _GUICtrlListView_SetItemCount( $idListview, 3 ) _GUICtrlListView_AddArray( $idListview, $packerList ) _GUICtrlListView_DeleteItem( $idListview, 0 ) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $tInfo, $tBuffer, $tBuffer2 $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $iIDFrom Case $idListview Switch $iCode Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam) GUICtrlSetData( $cInput, _GUICtrlListView_GetItemText($idListview, DllStructGetData($tInfo, "Index")) ) GUIDelete( $packersGUI ) Return 0 EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc -
By TrickyDeath
Hello everyone,
Have a tricky question:
How i manage to exit from loop, but not from script?
(ExitLoop it is ok, but runned out of ways, how to use it in my script )
With this i have a problem:
If i unpause (F2) the script, it will continue the loop.
While scrip is paused (F2) i can restart it (F1), but:
While script is paused (F2), and i open my form (F3), and try to press button on it, it will not work, cause active loop is paused at background. (I hope i understand right the method)
#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> HotKeySet("{F1}", "RunScript") HotKeySet("{F2}", "Pause") HotKeySet("{F3}", "OpenForm") Global $Pause $GUI_Create_Form = GUICreate("Settings", 175, 95) $Button_Save = GUICtrlCreateButton("Save", 10, 60, 75, 25) $Button_Cancel = GUICtrlCreateButton("Cancel", 90, 60, 75, 25) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $Button_Save MsgBox(0, "Notification", "Settings have been saved!", 1) GUISetState(@SW_HIDE) Case $Button_Cancel GUISetState(@SW_HIDE) EndSwitch WEnd Func RunScript() Local $Numbers = 1 While 1 $Numbers = $Numbers + 1 Sleep(250) ToolTip("Numbers:" & $Numbers, 0, 0) WEnd EndFunc ;==>RunScript Func Pause() $Pause = Not $Pause While $Pause Sleep(100) ToolTip('Scrpit is "Paused"', 0, 0) WEnd ToolTip("", 0, 0) EndFunc ;==>Pause Func OpenForm() GUISetState() EndFunc ;==>OpenForm All i want is, brake the counter loop with hotkey.
Can anyone help me to give a logical answare?
(I do need the form with buttons, to store data / save settings)
-
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now