jonai Posted November 10, 2015 Posted November 10, 2015 (edited) Hello,I am very new in AutoIt, and my programming skills are few. I'm doing a macro to repeat certain keystrokes, and so far I have succeeded. But I need to stop the script when the check fails to continue and I do not know how.I have to check in a strange way because all text in the window is hidden and the screen change certain texts and that's what I check.What I need is that instead of "exit" the program stops and start again from the button.Here is the code I have done so far.A greetingexpandcollapse popup#cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.14.2 Author: myName Script Function: Template AutoIt script. #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> $Dateactual = @MDAY & '_' & @MON & '_' & @YEAR $Dateactual2 = @MDAY & @MON & @YEAR $ruta ="C:\Users\11oe0053\Desktop\koda\" $folder= $ruta & $Dateactual If Not FileExists ($folder) Then DirCreate ($folder) EndIf #Region ### START Koda GUI section ### Form=c:\koda\conformator10.kxf $Form1_1 = GUICreate("Form1", 429, 361, 299, 151) $CONFORMATOR = GUICtrlCreateLabel("CONFORMATOR V 1.0", 16, 24, 350, 45) GUICtrlSetFont(-1, 22, 800, 0, "Arial Black") GUICtrlSetColor(-1, 0x000000) $Checkbox1 = GUICtrlCreateCheckbox("NIE", 16, 88, 57, 25) $Input1 = GUICtrlCreateInput("DNI/NIE", 88, 88, 137, 21) $Label1 = GUICtrlCreateLabel("SOLICITANTE", 16, 72, 74, 17) $Label2 = GUICtrlCreateLabel("CÓNYUGE/PAREJA", 16, 120, 103, 17) $Checkbox2 = GUICtrlCreateCheckbox("NIE", 16, 140, 57, 25) $Input2 = GUICtrlCreateInput("DNI/NIE", 88, 144, 137, 21) $Checkboxpar = GUICtrlCreateCheckbox("C", 240, 140, 25, 25) $Label3 = GUICtrlCreateLabel("HIJO 01", 16, 176, 43, 17) $Checkbox3 = GUICtrlCreateCheckbox("NIE", 16, 192, 49, 33) $Input3 = GUICtrlCreateInput("DNI/NIE", 88, 200, 137, 21) $Label4 = GUICtrlCreateLabel("HIJO 02", 16, 232, 43, 17) $Checkbox4 = GUICtrlCreateCheckbox("NIE", 16, 248, 57, 33) $Input4 = GUICtrlCreateInput("DNI/NIE", 88, 256, 137, 21) $Label5 = GUICtrlCreateLabel("HIJO 03", 16, 288, 43, 17) $Checkbox5 = GUICtrlCreateCheckbox("NIE", 16, 304, 49, 25) $Input5 = GUICtrlCreateInput("DNI/NIE", 88, 304, 137, 21) $Button1 = GUICtrlCreateButton("DATOS SI", 272, 88, 129, 33) $Button2 = GUICtrlCreateButton("DATOS VL", 272, 128, 129, 33) $Button3 = GUICtrlCreateButton("DATOS GE", 272, 168, 129, 33) $Button4 = GUICtrlCreateButton("DATOS CI", 272, 208, 129, 33) $Button5 = GUICtrlCreateButton("GENERAR INFORME", 272, 274, 129, 33) $Button6 = GUICtrlCreateButton("REINICIAR", 272, 312, 129, 33) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### HotKeySet("{ESC}", "_Terminate") WinSetState ( "CAROL", "", @SW_MAXIMIZE ) WinActivate ( "CAROL" ) While 1 Switch GUIGetMsg() Case $Button1 $data1 = GUICtrlRead($Input1) $data2 = GUICtrlRead($Input2) $data3 = GUICtrlRead($Input3) $data4 = GUICtrlRead($Input4) $data5 = GUICtrlRead($Input5) If $data1 = "DNI/NIE" Then MsgBox($MB_OK, "ERROR", "No has introducido ningún dato") EndIf $folder2= $ruta & $Dateactual & "\" & $data1 If Not FileExists ($folder2) Then DirCreate ($folder2) EndIf Local $i = 0 Local $times = 0 Do Send ("{ALT}+{e}") Send ("{s}") Send ("{ALT}+{e}") Send ("{ENTER}") $comparativo = ClipGet() If StringRegExp($comparativo, "CHECKTEXT2") Then Send ( $data1 ) Send ("{ENTER}") $i = 1 Else Sleep(100) $times = $times + 1 EndIf Until $i = 1 Or $times = 10; Increase the value of $i until it equals the value of 10. If $times = 10 Then MsgBox(0, "INFO", "No estás en la pantalla de Salida DSCP21 o el Sistema está muy lento") Exit ; CHANGE THIS FOR STOP THE SCRIPT I'DON'T KNOW HOW EndIf ; I REPEAT THE SAME IN ANOTHER SCREEN OF THE SAME WINDOW Local $i = 0 Local $times = 0 Do Send ("{ALT}+{e}") Send ("{s}") Send ("{ALT}+{e}") Send ("{ENTER}") $comparativo = ClipGet() If StringRegExp($comparativo, "CHECKTEXT2") Then Send ( $data1 ) Send ("{ENTER}") $i = 1 Else Sleep(100) $times = $times + 1 EndIf Until $i = 1 Or $times = 10; Increase the value of $i until it equals the value of 10. If $times = 10 Then MsgBox(0, "INFO", "No estás en la pantalla de Salida DSCP21 o el Sistema está muy lento") Exit ; CHANGE THIS FOR STOP THE SCRIPT I'DON'T KNOW HOW EndIf Case $Button2 GUISetState(@SW_MINIMIZE) Case $Button6 GUICtrlSetData($Input1, "DNI/NIE") GUICtrlSetData($Input2, "DNI/NIE") GUICtrlSetData($Input3, "DNI/NIE") GUICtrlSetData($Input4, "DNI/NIE") GUICtrlSetData($Input5, "DNI/NIE") Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Edited November 10, 2015 by jonai
mikell Posted November 10, 2015 Posted November 10, 2015 (edited) Exit => Continueloop Edited November 10, 2015 by mikell
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