Rubinho Posted July 14, 2017 Share Posted July 14, 2017 Hi, I'm creating a script that will input products to an external program going thrue different screens in that program. The script itself works, but the external program gives frequently errormessages (always same text) and i need to catch this everytime it occurs, so i can restart inserting the product. How can i add a kind of a listener/watch to this error message and stop my current function to take action? In attachment, you can find the external program with its errormessage. Thanks, Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted July 16, 2017 Moderators Share Posted July 16, 2017 @Rubinho look at AdLibRegister in the help file. You can create a function that checks for the existence of the error message and handles appropriately. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
mikell Posted July 16, 2017 Share Posted July 16, 2017 Or you could try a shell hook (example below) expandcollapse popup#include <WindowsConstants.au3> #include <GUIConstantsEx.au3> Opt("GUIOnEventMode", 1) $hGui = GUICreate("test", 200, 50, -1, 10) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") GUIRegisterMsg(RegisterWindowMessage("SHELLHOOK"), "HShellWndProc") GUISetState() ShellHookWindow($hGui, 1) Sleep(1000) ; test msgbox(0 ,"Foutmelding", "window with title Foutmelding") While 1 Sleep(1000) WEnd Func HShellWndProc($hWnd, $Msg, $wParam, $lParam) Switch $wParam Case 1 ; $HSHELL_WINDOWCREATED If WinExists("Foutmelding") Then Msgbox(0, "", "error") EndSwitch EndFunc ;register/unregister ShellHook Func ShellHookWindow($hWnd, $bFlag) Local $sFunc = 'DeregisterShellHookWindow' If $bFlag Then $sFunc = 'RegisterShellHookWindow' Local $aRet = DllCall('user32.dll', 'int', $sFunc, 'hwnd', $hWnd) Return $aRet[0] EndFunc ;register window message Func RegisterWindowMessage($sText) Local $aRet = DllCall('user32.dll', 'int', 'RegisterWindowMessage', 'str', $sText) Return $aRet[0] EndFunc Func _Exit() ShellHookWindow($hGui, 0) Exit EndFunc Link to comment Share on other sites More sharing options...
Rubinho Posted July 18, 2017 Author Share Posted July 18, 2017 Thanks a lot, I'll give it a try in one of the coming days! Link to comment Share on other sites More sharing options...
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