Is there any way to stop the script when an error message pops up? What I am thinking is that, in case there is an error message while the script is being performed, then the script will immediately end.
One thing I thought of is to use Image Recognition to scan the error message if it pops up, but is it possible for it to make this work for the duration of the script?
Thanks for reading.
Prompt Script End if Error Message is encountered.
Moderators: Dorian (MJT support), JRL
Look at help for OnEvent> You could use image recognition in a custom event. (might be a lot of overhead and slow things down) Or you might be able to perform an action (such as Exit>) based on the error window name.
I see. However, since the error message of the program I am using is quite similar to the name of the non-error portions of the program, it would be difficult to use the window name, which is why I am looking into image recognition here.JRL wrote:Look at help for OnEvent> You could use image recognition in a custom event. (might be a lot of overhead and slow things down) Or you might be able to perform an action (such as Exit>) based on the error window name.
Is there any way to disable the event (because I won't want to repeat the handling as long as the image is on-screen.
Thanks for reading.
PPQ
Here's a couple of samples. The first uses image recognition and the second uses text comparison. Both methods have good points and bad points. If they both work, use the one that suits you. If neither work let us know and we'll try something else.
The Window_NewActive event handler activates every time a new window pops up. It doesn't repeat, it only activates at that moment when a new active window displays. Its my favorite method of dealing with sporadic windows. I have a script that happens to be running on another computer at this moment, where the Window_NewActive event handler deals with more than 20 different windows that might pop up during the process the script is controlling.
Image recognition on a newly activated window
Text comparison on a newly activated window
The Window_NewActive event handler activates every time a new window pops up. It doesn't repeat, it only activates at that moment when a new active window displays. Its my favorite method of dealing with sporadic windows. I have a script that happens to be running on another computer at this moment, where the Window_NewActive event handler deals with more than 20 different windows that might pop up during the process the script is controlling.
Image recognition on a newly activated window
Code: Select all
OnEvent>WINDOW_NEWACTIVE,0,0,CheckOutThisWindow
Let>NeedleFileName=C:\MyPath\MyBMPfile.BMP
SRT>CheckOutThisWindow
FindImagePos>NeedleFileName,SCREEN,0,1,X_pos,Y_pos,NumFound
If>NumFound>0
//Do what needs to be done for this particular window.
EndIf
END>CheckOutThisWindow
Code: Select all
OnEvent>WINDOW_NEWACTIVE,0,0,CheckOutThisWindow
//Text is case sensitive
Let>TextToCompare=Something is BROKEN!
SRT>CheckOutThisWindow
Let>WIN_USEHANDLE=1
GetActiveWindow>CurWinHandle,CurWinX,CurWinY,CurWinW,CurWinH
GetWindowTextEx>CurWinHandle,WindowTextResult
Let>WIN_USEHANDLE=0
Separate>WindowTextResult,TextToCompare,CompareTextResult
If>CompareTextResult_Count>1
//Do what needs to be done for this particular window.
EndIf
END>CheckOutThisWindow