Andreik Posted July 5, 2023 Posted July 5, 2023 Try something like this: AutoItSetOption('WinTitleMatchMode', 2) While True If WinExists('Error') Then $sTitle = WinGetTitle('Error') $sText = WinGetText('Error') ConsoleWrite('Window title: ' & $sTitle & @CRLF) ConsoleWrite('Window text: ' & $sText & @CRLF) EndIf Sleep(10) WEnd It should catch the error window.
Docfxit Posted July 5, 2023 Author Posted July 5, 2023 (edited) How can I cancel out of a loop? I got it. <ctrl> Break Edited July 5, 2023 by Docfxit
Andreik Posted July 5, 2023 Posted July 5, 2023 Tray icon, task manager, etc Or you can register a hotkey to exit for further runs.
Docfxit Posted July 5, 2023 Author Posted July 5, 2023 The console shows: Window title: Error Recovery Guide Window text: Tab1 More Info... No Information on the scanner hardware status.
Andreik Posted July 5, 2023 Posted July 5, 2023 Ok, I suppose you can MsgBox these info and do whatever you need after that (log error, send enter to continue, etc).
Docfxit Posted July 5, 2023 Author Posted July 5, 2023 I need to figure out how to incorporate it into my original code so It's looking for all the errors.
Docfxit Posted July 5, 2023 Author Posted July 5, 2023 This is what I came up with. It's still not catching the error. expandcollapse popupOpt("WinWaitDelay", 100) Opt("WinTitleMatchMode", 2) Opt("WinDetectHiddenText", 1) Opt("MouseCoordMode", 0) Opt("TrayAutoPause", 0) #include "Notify.au3" #include "StringSize.au3" #include <MsgBoxConstants.au3> AutoItSetOption("TrayIconDebug", 1) ;0-off ; Set so that tray displays current line number ; Press ESC to exit script HotKeySet("{ESC}", "_Exit") Dim $ErrorCount, $textLine ; Register message for click event _Notify_RegMsg() ; Set notification location _Notify_Locate(0) _Notify_Set(Default) ; Show notifications Global $aNotCID[5] ;$aNotCID[1] = _Notify_Show(0, "", "Message 2" & @CRLF & "more Message 2") ;$aNotCID[4] = _Notify_Show(0, "DAZzle 3", "Auto-retract", 1) While 1 WinExists("DAZzle Professional") If Not WinActive("DAZzle Professional", "") Then WinActivate("DAZzle Professional", "") Local $title = WinGetTitle("DAZzle Professional", "") MsgBox($MB_SYSTEMMODAL, "", "Full title read is: " & $title) Local $text = WinGetText("", "") ;MsgBox(4096, "", "Full text read is: " & StringStripWS(StringReplace($text, @CRLF, ' '), 7)) MsgBox(4096, "", "Full text read is: " & StringStripWS(StringReplace(StringReplace($text, Chr(0), ''), @CRLF, ' '), 7)) ;ConsoleWrite ( StringStripWS(StringReplace($text, @CRLF, ' '), 7)) $file = FileOpen("\Dnload\DazzleErrorFix.txt", 2) FileWrite($file, StringStripWS(StringReplace($text, @CRLF, ' '), 7)) FileClose($file) If $title = "DAZzle Professional" And $text = "The file DAZzle Prof" Then $ErrorCount = $ErrorCount + 1 $aNotCID[1] = _Notify_Show(0, "DAZzle 2", "The file DAZzle Prof") Send("{ENTER}") EndIf ;If $title = "Error" And $text = "The remote server returned" Then ; $ErrorCount = $ErrorCount + 1 ; $aNotCID[3] = _Notify_Show(0, "DAZzle 4", "The remote server") ; Send("{ENTER}") ;EndIf If $title = "DAZzle Professional" And $text = "Error from CreateLab" Then $ErrorCount = $ErrorCount + 1 $aNotCID[4] = _Notify_Show(0, "DAZzle 5", "Error from CreateLab" & @CRLF & "more Message 4") Send("{ENTER}") EndIf If $title = "DAZzle Professional" And $text = "Failed to complete t" Then $ErrorCount = $ErrorCount + 1 $aNotCID[5] = _Notify_Show(0, "DAZzle 6", "Failed to complete" & @CRLF & "more Message 4") Send("{ENTER}") EndIf WinExists("Error") If Not WinActive("Error", "") Then WinActivate("Error", "") Local $title = WinGetTitle("Error", "") MsgBox($MB_SYSTEMMODAL, "", "Full title read is: " & $title) Local $text = WinGetText("", "") ;MsgBox(4096, "", "Full text read is: " & StringStripWS(StringReplace($text, @CRLF, ' '), 7)) MsgBox(4096, "", "Full text read is: " & StringStripWS(StringReplace(StringReplace($text, Chr(0), ''), @CRLF, ' '), 7)) If $title = "Error" And $text = "Tab1" Then $ErrorCount = $ErrorCount + 1 $aNotCID[2] = _Notify_Show(0, "DAZzle 3", "The remote server" & @CRLF & "more Message 4") Send("{ENTER}") EndIf If $ErrorCount > 0 Then $aNotCID[0] = _Notify_Show(0, "DAZzle 1", "Errors Found: " & $ErrorCount, 8) EndIf Sleep(8000) ; For debug purposes only For $i = 0 To 4 $sRet = _CheckRetractionMethod($aNotCID[$i]) If $sRet Then ConsoleWrite("Notification " & $i + 1 & ": " & $sRet & @CRLF) EndIf Next WEnd Func _CheckRetractionMethod($hWnd) Local $sRet = "" ; Check if notification was the last clicked Local $aFuncRet = _Notify_RetractCheck($hWnd) ; Determine method of retraction Switch $aFuncRet[0] Case 0 ; Do nothing - notification either still visible or already retracted Case 1 $sRet = "Title clicked :: " & $aFuncRet[1] Case 2 $sRet = "Message clicked :: " & $aFuncRet[1] Case 9 $sRet = "Timeout :: " & $aFuncRet[1] EndSwitch Return $sRet EndFunc ;==>_CheckRetractionMethod Func _Exit() Exit EndFunc ;==>_Exit
Andreik Posted July 5, 2023 Posted July 5, 2023 Try this: expandcollapse popupAutoItSetOption("WinWaitDelay", 100) AutoItSetOption("WinTitleMatchMode", 2) AutoItSetOption("WinDetectHiddenText", 1) AutoItSetOption("MouseCoordMode", 0) AutoItSetOption("TrayAutoPause", 0) #include "Notify.au3" #include "StringSize.au3" #include <MsgBoxConstants.au3> AutoItSetOption("TrayIconDebug", 1) ;0-off ; Set so that tray displays current line number ; Press ESC to exit script HotKeySet("{ESC}", "_Exit") Dim $ErrorCount, $textLine ; Register message for click event _Notify_RegMsg() ; Set notification location _Notify_Locate(0) _Notify_Set(Default) ; Show notifications Global $aNotCID[5] ;$aNotCID[1] = _Notify_Show(0, "", "Message 2" & @CRLF & "more Message 2") ;$aNotCID[4] = _Notify_Show(0, "DAZzle 3", "Auto-retract", 1) Global $sTitle, $sText While 1 If WinExists('DAZzle Professional') Then $sTitle = WinGetTitle('DAZzle Professional') $sText = WinGetText('DAZzle Professional') MsgBox(4096, $sTitle ,StringStripWS(StringReplace(StringReplace($sText, Chr(0), ''), @CRLF, ' '), 7)) Switch $sText Case "The file DAZzle Prof" $ErrorCount = $ErrorCount + 1 $aNotCID[1] = _Notify_Show(0, "DAZzle 2", "The file DAZzle Prof") Send("{ENTER}") Case "Error from CreateLab" $ErrorCount = $ErrorCount + 1 $aNotCID[4] = _Notify_Show(0, "DAZzle 5", "Error from CreateLab" & @CRLF & "more Message 4") Send("{ENTER}") Case "Failed to complete t" $ErrorCount = $ErrorCount + 1 $aNotCID[5] = _Notify_Show(0, "DAZzle 6", "Failed to complete" & @CRLF & "more Message 4") Send("{ENTER}") EndSwitch EndIf If WinExists('Error') Then $sTitle = WinGetTitle('Error') $sText = WinGetText('Error') MsgBox(4096, $sTitle ,StringStripWS(StringReplace(StringReplace($sText, Chr(0), ''), @CRLF, ' '), 7)) Switch $sText Case "The remote server re" $ErrorCount = $ErrorCount + 1 $aNotCID[2] = _Notify_Show(0, "DAZzle 3", "The remote server" & @CRLF & "more Message 4") Send("{ENTER}") Case "The remote server returned" Then $ErrorCount = $ErrorCount + 1 $aNotCID[3] = _Notify_Show(0, "DAZzle 4", "The remote server") Send("{ENTER}") EndSwitch EndIf If $ErrorCount > 0 Then $aNotCID[0] = _Notify_Show(0, "DAZzle 1", "Errors Found: " & $ErrorCount, 8) EndIf Sleep(8000) ; For debug purposes only For $i = 0 To 4 $sRet = _CheckRetractionMethod($aNotCID[$i]) If $sRet Then ConsoleWrite("Notification " & $i + 1 & ": " & $sRet & @CRLF) EndIf Next WEnd Func _CheckRetractionMethod($hWnd) Local $sRet = "" ; Check if notification was the last clicked Local $aFuncRet = _Notify_RetractCheck($hWnd) ; Determine method of retraction Switch $aFuncRet[0] Case 0 ; Do nothing - notification either still visible or already retracted Case 1 $sRet = "Title clicked :: " & $aFuncRet[1] Case 2 $sRet = "Message clicked :: " & $aFuncRet[1] Case 9 $sRet = "Timeout :: " & $aFuncRet[1] EndSwitch Return $sRet EndFunc ;==>_CheckRetractionMethod Func _Exit() Exit EndFunc ;==>_Exit
Docfxit Posted July 5, 2023 Author Posted July 5, 2023 (edited) It isn't catching the window. I tried changing one of the errors with the text of Tab1. It still doesn't catch it. If WinExists('Error') Then $sTitle = WinGetTitle('Error') $sText = WinGetText('Error') MsgBox(4096, $sTitle ,StringStripWS(StringReplace(StringReplace($sText, Chr(0), ''), @CRLF, ' '), 7)) Switch $sText Case "Tab1" $ErrorCount = $ErrorCount + 1 $aNotCID[2] = _Notify_Show(0, "DAZzle 3", "The remote server" & @CRLF & "more Message 4") Send("{ENTER}") Case "The remote server returned" $ErrorCount = $ErrorCount + 1 $aNotCID[3] = _Notify_Show(0, "DAZzle 4", "The remote server") Send("{ENTER}") EndSwitch EndIf Edited July 5, 2023 by Docfxit
Andreik Posted July 5, 2023 Posted July 5, 2023 You must be more specific what is not catching. I see the MsgBox with some data there.
Andreik Posted July 5, 2023 Posted July 5, 2023 This is not going to work. I can't help you without having the app that generates these errors and without the AutoIt Info Tool. Maybe listing all the windows WinList() and looking for your specific window will help you to identify the window.
Docfxit Posted July 5, 2023 Author Posted July 5, 2023 I used this code: #include <MsgBoxConstants.au3> Example() Func Example() ; Retrieve a list of window handles. Local $aList = WinList() ; Loop through the array displaying only visable windows with a title. For $i = 1 To $aList[0][0] If $aList[$i][0] <> "" And BitAND(WinGetState($aList[$i][1]), 2) Then MsgBox($MB_SYSTEMMODAL, "", "Title: " & $aList[$i][0] & @CRLF & "Handle: " & $aList[$i][1]) EndIf Next EndFunc ;==>Example And it gave me this window:
Docfxit Posted July 5, 2023 Author Posted July 5, 2023 Do you have any idea how I could fix AutoIt Info Tool?
Docfxit Posted July 5, 2023 Author Posted July 5, 2023 Would it help if you changed this code: #include <MsgBoxConstants.au3> Example() Func Example() ; Retrieve a list of window handles. Local $aList = WinList() ; Loop through the array displaying only visable windows with a title. For $i = 1 To $aList[0][0] If $aList[$i][0] <> "" And BitAND(WinGetState($aList[$i][1]), 2) Then MsgBox($MB_SYSTEMMODAL, "", "Title: " & $aList[$i][0] & @CRLF & "Handle: " & $aList[$i][1]) EndIf Next EndFunc ;==>Example To create a list of open windows with their text?
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