Jump to content

Recommended Posts

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

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

 

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...