
JailDoctor
Active Members-
Posts
118 -
Joined
-
Last visited
Content Type
Forums
Downloads
Forum Articles
Events
Everything posted by JailDoctor
-
I'm trying this new things in red, but the status of the sound escapes the Function call even checking every 100 miliseconds.
-
I need to detect if the default beep was played by a program. I'm working with this "Extra program" (looks like a DOS box) to check if an inmate is still in the building. When the inmate is no longer in the building "NO INMATE FOUND" appears in the box and a beep is played. AutoIt Window Info does not detect any of the text (visible or hidden) so, I can't use the text to make a list of people to clear from my patient roster. Does anyone know how to check if a wav was played? The beep only plays if there is no match in the search. Here is the code I have. It works fine for a few people, placing a MsgBox before WEnd, but I have to check over 9,000 people in the database. CODE;Set a hotkey combo for exit HotKeySet("{ESC}", "MyExit") #include <file.au3> #include <GUIConstants.au3> $Password = InputBox("Jail Daily Password", "Enter your daily password") ; Get the ID numbers from Sick Call List.txt ;Create arrays from the content of the file $file = FileOpen(@DesktopDir & "\Sick Call List.txt", 0) ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf WinActivate("Jail - EXTRA! Office Client") WinWaitActive("Jail - EXTRA! Office Client") ; Read in lines of text until the EOF is reached While 1 WinActivate("Jail - EXTRA! Office Client") WinWaitActive("Jail - EXTRA! Office Client") $line = FileReadLine($file) If $line = "" Then ExitLoop ;Stop on empty line. If @error = -1 Then ExitLoop Send($Password) Send($line) Send("{ENTER}") ;if the inmate is not found there is a beep now. I want to write the $line element in notepad whenever there is a beep played. WinWaitActive("Jail - EXTRA! Office Client") WEnd $destination = "c:\logo.bmp" Sleep(100) SplashImageOn("Script by JailDoctor", $destination, 150, 150) Sleep(3000) SplashOff() Func MyExit() Exit EndFunc ;==>MyExit
-
I figured out that H:\My Documents\multidimension.au3 (25) : ==> Subscript used with non-Array variable.: shows up whenever there is an error. So if I'm looking for a value that doesn't exist in the array , the error is reported as H:\My Documents\multidimension.au3 (25) : ==> Subscript used with non-Array variable.: So I spent all the time looking for answers in the code when I needed to check that the values were existant in the array. I am implementing a routine for dealing with the not found @error (I believe -1) and will keep you posted.
-
Thanks Kiti, it worked perfectly. So that's what Top-most Attribute set means. Do you know what the Modality choices mean? I selected Task Modal and System Modal and the only thing that happened is that there was no default beep during the procedure.
-
Ok, so they can't be moved. The MsbBox is centered so I move the user's application with WinMove ("YourWindow","", 540, 500) after the users do what the do and then the MsgBox (well, half of it) can be seen and they can click it to continue with the next instance of the original loop. Perhaps a "Rambo" approach but it works for now until I figure out how to position a MsgBox out of the way.
-
Yes, that is the proper way to use the set on top command, with a 'real" window. I need to keep a MsgBox visible while the user interacts with another application. Perhaps moving the MsBox to a specified place. Can MsgBoxes be moved?
-
It would need a number one at the end to stay on top. WinSetOnTop("Hello","",1) But still doesn't work for MsgBox
-
Thanks, we just need to add the number one at the end to make it stay on top. WinSetOnTop("Hello","",1);
-
How would I make a msgbox stay on top?
-
By looking at the _ExcelReadArray line, describing the rows and columns as row 8, colum 5, then 8,1 and then 8,7 it follows the format should be $XLLastCell[1] -The last cell used, in R1C1 format. But I get this error. H:\My Documents\multidimension.au3 (25) : ==> Subscript used with non-Array variable.: $XLArray =_ExcelReadArray($oExcel, 8, 5, $XLLastCell[1], 1) $XLArray =_ExcelReadArray($oExcel, 8, 5, $XLLastCell^ ERROR ->15:34:52 AutoIT3.exe ended.rc:1 All other possibilities, [0] for A1, [2] for column, and [3] for row caused the very same error. Any ideas?
-
I got this error. H:\My Documents\ExcelCom_UDF.au3 (606) : ==> Array variable subscript badly formatted.: Local $aArray[$iNumCells + $iIndexBase] Local $aArray[^ ERROR ->13:39:13 AutoIT3.exe ended.rc:1 It seems ExcelCom_UDF.au3 doesn't understand to look up to the last cell? CODE$oExcel = _ExcelBookOpen($XLFilePath) $XLFilePath=@TempDir & ("\My test.xls") $XLLastCell = _ExcelSheetUsedRangeGet($oExcel, _ExcelSheetNameGet($oExcel)) $XLArray =_ExcelReadArray($oExcel, 8, 5, 500, 1) $XLArrayName =_ExcelReadArray($oExcel, 8, 1, 500, 1) $XLArrayVisitStatus =_ExcelReadArray($oExcel, 8, 7, 500, 1) _ExcelBookClose($oExcel)
-
It worked pretty well, although kind of slow. I was looking for searching for not equal to "ADM" to speed things up (or for future new codes) but <> does not work for strings.I tried all combinations of operators but it didn't work. Any suggestions? Thanks Kerros, your idea got me learning about multidimensional arrays, but it is difficult to find much info about using them. It took me a while to populate the arrays from Excel, but I finally did it.
-
Thanks, I removed the line with all the other comments and "tests" for clarity.I fixed the post. $XLArray =_ExcelReadArray($oExcel, 8, 5, 500, 1)
-
Clt Name Number Status John Doe 123456 ADM Jane Sam 789100 CAN Billy Bob 223344 ADM John Doe and Billy Bob have active visits (ADM), Jane canceled her visit (CAN). I want to let the operator know that Jane canceled her visit and hence will not be processed and delete the item from my arrays. So a notepad will run with the list of all the canceled visits.
-
I extract three arrays from an excel spreadsheet. They represent the Client's name, visit number and if the visit was canceled. Canceled visits are entered as CAN, and active visits are entered as ADM in the spreadsheet. I want to delete the canceled visits (not active visits) and their corresponding names, and number from the other 2 arrays. So far I can find the canceled visits, but I can't figure out how to write in an error log that Mr. John Does' visit was canceled, and how to delete the elements in the other two arrays corresponding to the canceled visit. This is the what I have so far. CODE#include"ExcelCom_UDF.au3" #include"Array.au3" #include"File.au3" Global $XLFilePath = @TempDir & "\TestList.xls" Global $oExcel, $XLArray, $XLArrayName, $XLArrayVisitStatus ;Create an errorLog $sFile = @DesktopDir & "\ErrorLog.txt" $oExcel = _ExcelBookOpen($XLFilePath) $XLFilePath=@TempDir & ("\TestList.xls") $XLArray =_ExcelReadArray($oExcel, 8, 5, 500, 1) ;corrected $XLArrayName =_ExcelReadArray($oExcel, 8, 1, 500, 1) $XLArrayVisitStatus =_ExcelReadArray($oExcel, 8, 7, 500, 1) _ExcelBookClose($oExcel) ; Remove blank elements from Number For $n = UBound($XLArray) - 1 To 0 Step -1 If StringStripWS($XLArray[$n], 8) = "" Then _ArrayDelete($XLArray, $n) Next ; Remove blank elements from Name For $n = UBound($XLArrayName) - 1 To 0 Step -1 If StringStripWS($XLArrayName[$n], 8) = "" Then _ArrayDelete($XLArrayName, $n) Next ; Remove blank elements Visit For $n = UBound($XLArrayVisitStatus) - 1 To 0 Step -1 If StringStripWS($XLArrayVisitStatus[$n], 8) = "" Then _ArrayDelete($XLArrayVisitStatus, $n) Next _ArrayDisplay( $XLArray, "Number") _ArrayDisplay( $XLArrayName, "Name") _ArrayDisplay( $XLArrayVisitStatus, "Status") ;find the canceled visits $CanceledVisit = _ArrayFindAll ($XLArrayVisitStatus, "CAN") _ArrayDisplay( $CanceledVisit, "Visit Status") ; Write first canceled visit to the error log _FileWriteFromArray($sFile, $XLArray, 0) Run("notepad.exe " & @DesktopDir & ("\ErrorLog.txt"))
-
Filecountlines gives negative number
JailDoctor replied to leuce's topic in AutoIt General Help and Support
I tried this to solve a similar problem with your code and it didn't help. I create a txt file with an array from and excel sheet. They are sets of numbers, and usually are 2 to 200 or so. To be open to growth, I specify a top of 493 rows by the line: $XLArray = _ExcelReadArray($oExcel, 1, 1, 493, 1) Only the occupied cells should be placed in the txt file by: _FileWriteFromArray($sFile, $XLArray, 0) When I want to read the number of lines in the text file by $CountLines = _FileCountLines(@DesktopDir & "\My Test List.txt") I get 493 instead of 10 or whatever number is in the file. How can I solve this problem? Here is my code: CODEinclude <file.au3> #include <ExcelCOM_UDF.au3> Global $XLFilePath = @DesktopDir & "\uh_patsumlc_MRNOnly.xls" Global $oExcel, $XLArray $oExcel = _ExcelBookOpen($XLFilePath, @SW_HIDE) $XLArray = _ExcelReadArray($oExcel, 1, 1, 493, 1) ;here is where I determine how many rows to read Row 1, Column A, 493 rows, and direction down) _ExcelBookClose($oExcel) $sFile = @TempDir & "\My Test List.txt" ; Write first array to file by string file name _FileWriteFromArray($sFile, $XLArray, 0) $CountLines = _FileCountLines(@DesktopDir & "\My Test List.txt") ;your code: $wftm = FileOpenDialog ("Select file", "", "Files (*.txt)") $wftmfile = FileOpen ($wftm, 0) $wflines = _CountLinsInFile($wftm) MsgBox (0, "foo", $wflines) Func _CountLinsInFile($File) If Not FileExists($File) Or StringInStr(FileGetAttrib($File), "D") Then Return SetError(1, 0, 0) StringReplace(FileRead($File), @LF, "") Return @extended+1 EndFunc Exit -
The reason it skips the error loop is because the the value of $Flowcast is False until after the error loop. The Function does work because it changes the value of $Flowcast to True. (I put MsgBoxes with the $Flowcast value all over the loop and in the Function after changing the value). But this happens after reading the standard false value before the error loop, not before. How do I time the flag value so it is true before the error loop? Once again I'm stuck. And I thought this would be an easy one.
-
I get it.Ok, so Ihave the function already. When the Flowcast window appears, the function changes the value of the flag $Flowcast to True. So now that $Flowcast is true, it should follow the lines between If and EndIf, right? Somehow, it gets to where it clicks the Flowcast window's OK button ControlClick("Flowcast", "OK",""), and then jumps all the F7Q needed to go back to the original screen. Enters the letter N, and then the $Location variable. As in the lines after EndIf. I am obtunded. Please help!
-
I don't understand the ControlSend("Error Popup", "", "", "!r"); Retry I created a function that changes the value of $fErrorPopup to True whenever the error window pops up. For some reason I can't get it to see the value. CODE$file = FileOpen(@TempDir & "\My Test List.txt", 0) ;Define from which file to read MRNs. If $file = -1 Then ; Check if the file can open. MsgBox(0, "Error", "Missing MRN List.") Exit EndIf While 1 Dim $Flowcast $Flowcast = False AdlibEnable("MYFlowcast") ;Check if the flag is true or false. Dim $line, $file $line = FileReadLine($file) ; Read the MRN number. If @error = -1 Then ExitLoop If $line = "" Then ExitLoop ;Stop on empty line. WinActivate("aixidx Winsock - IDXterm") ;Activate the external program. WinWaitActive("aixidx Winsock - IDXterm") Send(".") Send($line) ;send a period followed by the MRN number. Send("{ENTER}") Sleep(500) Send("TL") ;command to select a visit from a list. Sleep(500) WinWaitActive("aixidx Winsock - IDXterm") ;wait for the window Dim $Value $Value = InputBox("Visit Number", "Select the Visit Number you wish to change.", "1") ;Choose a Visit number from the visits shown (default is 1) If $Value = 0 Then Exit Send($Value) Send("{ENTER}") Sleep(300) ;Edit the visit. Send("E") ;To edit ;enter today's date. Send("T{ENTER}") ;for today ;check for wrong visit If $Flowcast = True Then ;Here is where I'm stuck. This should all be bypassed if $Flowcast is false, and run if True WinWait("Flowcast", "") ;this is the error window. If Not WinActive("Flowcast", "") Then WinActivate("Flowcast", "") WinWaitActive("Flowcast", "") ControlClick("Flowcast", "OK","") ;to get rid of the window WinWaitActive("Flowcast", "") Sleep (300) Send("{ENTER}");enter to get rid of a second Flowcast window that appears after Enter. ; Start all over. WinWait("aixidx Winsock - IDXterm", "") If Not WinActive("aixidx Winsock - IDXterm", "") Then WinActivate("aixidx Winsock - IDXterm", "") WinWaitActive("aixidx Winsock - IDXterm", "") Send("{F7}q{F7}q{F7}q1{ENTER}") ;all these keys are to go back to the initial screen and enter the same MRN number as before the Flowcast error window. MsgBox (0,"Cancelled Visit", "You selected a cancelled visit, Please try again.", 8000) 'Let the user know what to do. Send (".") Send ($line) $Value = InputBox("Visit Number", "Select the Visit Number you wish to change.", "1") If $Value = 0 Then Exit Send($Value) Send("{ENTER}") Sleep(300) ;Edit the visit. Send("E") ;enter today's date. Send("T{ENTER}") EndIf ;continue here if the flag $Flowcast is False. Sleep(300) ;Enter the time (now). Send("N{ENTER}") Sleep(300) Send($Location) Sleep(300) Send("{ENTER}") Sleep(300) Send("{F10}") Sleep(300) Send("{F10}") Sleep(300) Send("{F10}") Sleep(300) Send("{UP}") Sleep(300) WEnd Func MyFlowcast() If WinExists("Flowcast") Then $Flowcast = True ; If the window is present the flag is changed to True. ;ControlSend("Error Popup", "", "", "!r"); Retry -I don't understand this line. EndIf EndFunc
-
I did this part, so AdlibEnable("myadlib") checks for the pop up window with the error. Problem: A function resides out of the loop and can't go back to the loop after it is done. ERROR: 'ContinueLoop' not allowed outside loop. How do I continue the loop after a Function is called by AdlibEnable("myadlib")?
-
I thought that ContinueLoop would use the next variable to run the loop. ContinueLoop will test Sam and not Monica, who generated the error I want to correct. CODEFile.txt contains: Albert Michael Monica Sam Walter While 1 $line = FileReadLine(File.txt) WinActivate (External Application) Send ($line) ;Application asks a question $Value = InputBox("Gender", "Select the persons gender.") If $Value = 0 Then Exit Send($Value) ;here I test for error. So if Monica was assigned a male gender, an error occurs. ;I want to have Monica offered as an option again to select the correct gender MsgBox(6, "Good call", $line & is & $Value WEnd
-
I catch the erro window called Flowcast fine with: CODEIf WinExists("Flowcast") Then GUICreate("Wrong choice", 210, 80) $Label = GUICtrlCreateLabel("You selected a closed visit.!", 10, 10) $TryAgainID = GUICtrlCreateButton("Try Again", 10, 50, 50, 20) $SkipID = GUICtrlCreateButton("Skip", 80, 50, 50, 20) $ExitID = GUICtrlCreateButton("Exit", 150, 50, 50, 20) GUISetState() ; display the GUI Do $msg = GUIGetMsg() ;etc What I don't know how to do is: when the user clicks the "Try Again" button, repeat the loop with the same value so the user gets another chance to select the correct visit (or whatever the looped variable represents).
-
Well, its not really GOTO , I just call it that because of all the talk about how not necessary it is for AutoIt. I am learning AutoIt by reading forums, and the help file. For a newie like myself this is a wonderful scripting product. The question is how to repeat the last loop. So, when the script sees the window that pops up on an error, the user clicks on the "Try Again" button and the last variable is looped again. Is there such a command as repeat?
-
You are right! I was testing ContinueLoop, 1 Thinking this would tell the loop to go to the first loop. Any suggestions to GOTO the $Value Input box and enter the same array so the user chooses the right selection?
-
I just fixed the code bar, sorry.