4 posts in this topic
So I have a lot of different functions in the little program I'm making. Most of them use the Do statement, such as finding images, clicking buttons, etc.
The question I have is how would I be able to both
1) Create a hotkey to pause whatever I am doing at the moment. If I have to put something into every function in the program, I don't mind.
2) Create a hotkey to exit whatever I am doing and stop all loops or commands and bring back the main GUI?
I want creat GUI, have button 1 to 10, but only use loop for ... to ... step ... next.
I was pondering over a question with regards to the speeds of reading something and did not see this kind of question in a forum search.
The question: What is (technically) faster? Multiple reads from the same 3d array cell, or only once make a 'temp' variable from that cell and read the value from this? I don't know if either has any real impact at all anyway, but just wanted to ask anyway. :-)
There may be a difference if the value holds an integer or a string (or something else) but in my case, is a simple integer.
To hopefully clarify with a small bit of code:
$process = $start - 15 If $xy[$process] <> "x" Then If _ArraySearch($open, $process, 1, $open, 0, 0, 1, 1) <> -1 Then UpdateOpen($xy[$process], $closed) ElseIf $start > 0 And _ArraySearch($closed, $process, 1, $closed, 0, 0, 1, 0) = -1 Then Add_open($start, $closed, $counter, $process) EndIf EndIf You can read from this, that the array $closed is being read 3 times. And this goes on further in the code I did not show.
My question boils down to this, should I make a 'temp' variable to hold that $closed value until the function is done?
It may not have a real impact on my small script, but I really am interested in the answer at least.
I keep losing the count of my $r varable when I go into the dropdown () function and call the same function.
#include <Excel.au3> #include <AutoItConstants.au3> #include<GUIConstantsEx.au3> #include<EditConstants.au3> #include<GUIConstants.au3> Global $iBox, $oExcel, $oWorkbook, $r = 1, $x = 3 HowMany() Excel () Dropdown () Sleep (500) Func Dropdown () $list = GUICreate("Chart", 225, 80) $combobox = GUICtrlCreateCombo("Clinic 1", 10, 10, 120, 20) GUICtrlSetData(-1, "Clinic 2|Clinic 3|Clinic 4") $button = GUICtrlCreateButton("Select", 10, 40, 60, 20) GUISetState(@SW_SHOW) While 1 $guibox = GUIGetMsg() Select Case $guibox = $button Select Case GUICtrlRead($combobox) = "Clinic 1" GUIDelete($list) Auto () EndSelect Case $guibox = $GUI_EVENT_CLOSE EndSelect WEnd EndFunc Func HowMany() Local $iMsg While 1 ;~ Turn input into a number $iBox = Number(InputBox ("Regestration", "How Many Patients are there total?")) ;~ If user enters a string or cancels then get them to try again If $iBox = 0 Then $iMsg = MsgBox(1,'Regestration', 'Please enter a valid number') If $iMsg = 2 Then Exit Else ExitLoop EndIf WEnd EndFunc Func Excel() While ProcessExists("EXCEL.EXE") $ms = MsgBox(5,"","Process error. You have an Excel sheet open. You must close it in order to let this program work. Please close it now.") If $ms=2 Then Exit ;~ Doesn't require sleep since the script is paused by the MsgBox above ;~ Sleep(250) WEnd ;~ Shouldn't use Global Scope inside functions moved to top of script Local $sExcelFile = FileOpenDialog("Choose/Create Excel File", @ScriptDir, "(*.xlsx)") If FileExists($sExcelFile) Then ;~ Shouldn't use Global Scope inside functions moved to top of script $oExcel = _Excel_Open () $oWorkbook = _Excel_BookOpen($oExcel,$sExcelFile) ;this will open the chosen xls file. Else $oExcel = _Excel_Open() $oWorkbook = _Excel_BookNew($oExcel, 2);this is here to create the xls file if it does not exist. EndIf EndFunc Func Auto() Local $aArray1 = _Excel_RangeRead($oWorkbook) ;~ If $iBox is greater than no. of rows in $aArray then $iBox equals the number of rows in $aArray If $iBox > (UBound($aArray1) - 1) Then $iBox = UBound($aArray1) - 1 For $i = 2 To UBound($aArray1) - 1 ;$i =0 Start from row A If $aArray1[$i] = "" Then Continueloop $sR0 = $aArray1[$i] ;status $sR1 = $aArray1[$i] ;Last Name $sR2 = $aArray1[$i] ;First Name $sR3 = $aArray1[$i] ;DOB $sR4 = $aArray1[$i] ;Sex $sR5 = $aArray1[$i] ;Mailling Address $sR6 = $aArray1[$i] ;Zip $sR7 = $aArray1[$i] ;Phone # $sR8 = $aArray1[$i] ;Visit Reason $sR9 = $aArray1[$i] ;Insurance $sR10 = $aArray1[$i] ;Clinic $sR11 = $aArray1[$i] ;Provider $sR12 = $aArray1[$i] ;Appt Time $sR13 = $aArray1[$i] ;Appt Date WinWaitActive ("Untitled - Notepad") ControlSend("Untitled - Notepad", "", "", $sR1 & ',' & $sR2 & @CR) $r += 1 If $r > $iBox Then Exit Dropdown () Next EndFunc so the second time I choose clinic 1 I want it to go to the next row which would be Champ brett in my example excel.
I am new to AutoIt and programming in general so any help would be greatly appreciated!
I am trying to create a script mainly using MouseClick and WinWait in order to automate some web processes. However, due to the lag time of the web pages and fields, sometimes my script does not run properly and I need to rerun it. I am trying to create a script that will check to see if the final line of the script was properly executed and if not, rerun the program and increase a count. Ultimately I would like some sort of report that tells me how many times it took to run to completion and total time.
Does anyone have any suggestions as to which functions I can use to accomplish this? I am also open to any suggestions on a better process to ensure that my program runs to completion.
Thanks in advance!