Rubinho

Listener for errormessage while doing actions

4 posts in this topic

#1 ·  Posted

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,

 

 

screenshot.jpg

Share this post


Link to post
Share on other sites



#2 ·  Posted

@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.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#3 ·  Posted

Or you could try a shell hook (example below)

#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

 

Share this post


Link to post
Share on other sites

#4 ·  Posted

Thanks a lot,

I'll give it a try in one of the coming days!

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now