Detect an error window displayed randomly and send Enter
This script detects when a specific window appears, here as an example Dr Watson window. When it sees this window, it presses Enter. The script must be launched before running a process where the window can appear. It stays active by using the Sleep statement.
The script uses OnAction statement which is not available in Wintask Lite. You need WinTask full version to run it.
'Definition of the subroutine which is launched when the specified window appears,
'in our example Dr Watson window
Sub WinTerminate()
Disable(CloseDrWatson)
pause 5 secs
msgframe("Dr. Watson detected",1)
pause 2
UseWindow("DRWTSN32.EXE|NotifyDialog|Dr. Watson",1, NoActivate)
SendKeys("<Enter>")
removeframe(1)
Enable(CloseDrWatson)
EndSub
'Definition of the OnAction, every time the specified window appears, it calls
'the subroutine
OnAction CloseDrWatson
WinStatus(Exists, Exact)
inWindow("DRWTSN32.EXE|NotifyDialog|Dr. Watson")
DoSub WinTerminate
EndAction
'By inserting a SLEEP statement, the script does not end and the OnAction stays active
sleep()