willwatters Posted May 19, 2005 Share Posted May 19, 2005 The following code does not work. I want it to check throught the lifecyle of the script for any message boxes that appear which have a substring of the word 'error'. The MsgBox(4096, "Baji", "Unexpected error occurred", "") statement did not execute as expected. Please correct the code for me: ;/* check for unforeseen errors every 250 MS (i.e. checks for an error window to pop up unpredictably, etc) AdlibEnable("myadlib") Func myadlib() ;Searches for substring title search of "error" Opt("WinTitleMatchMode",2) Opt("WinWaitDelay",10) If WinActive("Error") OR WinActive("error") OR WinActive("ERROR") Then MsgBox(4096, "Baji", "Unexpected error occurred", "") Exit EndIf EndFunc sleep(2000) MsgBox(4096, "Error", "Test", "") Link to comment Share on other sites More sharing options...
GaryFrost Posted May 19, 2005 Share Posted May 19, 2005 don't think you can check for a message box using the adlib in the same script, i believe the message box stops the script untill it is closed. SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
willwatters Posted May 20, 2005 Author Share Posted May 20, 2005 don't think you can check for a message box using the adlib in the same script, i believe the message box stops the script untill it is closed.<{POST_SNAPBACK}>Are you stating that i include it in another script and use a #include in the main script?I tried this and I don't think it worked:;Main script#include "WriteToFile.au3" ;Need code to read in fields from other tables$Pre = 1sleep(2000)MsgBox(4096, "H Error H", "Test", "") ;WriteToFile.au3 script;/* check for unforeseen errors every 250 MS (i.e. checks for an error window to pop up unpredictably, etc)Func myadlib() ;Searches for substring title search of "error" Opt("WinTitleMatchMode",2) Opt("WinWaitDelay",10) ;If WinActive("Error") OR WinActive("error") OR WinActive("ERROR") Then If WinActive("Error") Then MsgBox(4096, "Baji", "Unexpected error occurred", "") Exit EndIfEndFuncIn the AutoIt help file it give me this as an example:AdlibEnable("myadlib");...ExitFunc myadlib() If WinActive("Error") Then ;... EndIfEndFunc Link to comment Share on other sites More sharing options...
herewasplato Posted May 20, 2005 Share Posted May 20, 2005 nope - I do not think gafrost was attempting to convey that idea... Within your main script you can launch a totally separate script that checks for your error windows. [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
willwatters Posted May 20, 2005 Author Share Posted May 20, 2005 nope - I do not think gafrost was attempting to convey that idea...Within your main script you can launch a totally separate script that checks for your error windows.<{POST_SNAPBACK}>What is the code to launch this separate script please? Link to comment Share on other sites More sharing options...
Blue_Drache Posted May 20, 2005 Share Posted May 20, 2005 What is the code to launch this separate script please?<{POST_SNAPBACK}>Run("blah.exe") Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache Link to comment Share on other sites More sharing options...
willwatters Posted May 20, 2005 Author Share Posted May 20, 2005 Run("blah.exe")<{POST_SNAPBACK}>Sorry i tried the following, but it did not work:;Main scriptRun("d:\documents and settings\wwa2b\Desktop\WriteToFile.exe")sleep(2000)MsgBox(4096, "H Error H", "Test", "") sleep(2000);WriteToFile.exe;/* check for unforeseen errors every 250 MS (i.e. checks for an error window to pop up unpredictably, etc)AdlibEnable("myadlib")Func myadlib() ;Searches for substring title search of "error" Opt("WinTitleMatchMode",2) Opt("WinWaitDelay",10) ;If WinActive("Error") OR WinActive("error") OR WinActive("ERROR") Then If WinActive("Error") Then MsgBox(4096, "Baji", "Unexpected error occurred", "") ;Exit EndIfEndFuncAm I doing this right or do you know the solution please? Link to comment Share on other sites More sharing options...
herewasplato Posted May 20, 2005 Share Posted May 20, 2005 (edited) Let me try and show you the concept: Download the two files attached to this post: Mainscript.au3 and MessageWatcher.au3 Put them in a folder named C:\Temp Run the script named Mainscript.au3 and read the message box from each script. Open each script and read the code and comments. I do not know why you would want to do this - so I may not understand exactly what you want. I do not understand this sentence at all: "...check throught the lifecyle of the script for any message boxes that appear which have a substring of the word 'error'..." ...but based on your code, I think that I've made something that you could use. hope this helps Edit - old attachments removed Edited October 20, 2006 by herewasplato [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
willwatters Posted May 23, 2005 Author Share Posted May 23, 2005 Let me try and show you the concept:Download the two files attached to this post:Mainscript.au3 and MessageWatcher.au3Put them in a folder named C:\TempRun the script named Mainscript.au3 and read the message box from each script.Open each script and read the code and comments.I do not know why you would want to do this - so I may not understand exactly what you want. I do not understand this sentence at all: "...check throught the lifecyle of the script for any message boxes that appear which have a substring of the word 'error'..."...but based on your code, I think that I've made something that you could use.hope this helps<{POST_SNAPBACK}>Sorry, I may have caused some confusion. If the application that i'm testing causes an error box to appear will the function AdlibEnable("myadlib"), below, work:AdlibEnable("myadlib")Func myadlib();Searches for substring title search of "error" Opt("WinTitleMatchMode",2)Opt("WinWaitDelay",10);If WinActive("Error") OR WinActive("error") OR WinActive("ERROR") ThenIf WinActive("Error") ThenMsgBox(4096, "Baji", "Unexpected error occurred", "")ExitEndIfEndFunc Link to comment Share on other sites More sharing options...
BigDaddyO Posted May 23, 2005 Share Posted May 23, 2005 (edited) Have you tried for the Adlib function to use if winexists instead of winactive? it's possible that the error message is displaying but not actually active. edit: As for the messagbox halting the script that is correct. I threw this together to test. if you use the sleep then the adlib works fine. if you use the message box then the adlib does nothing. $i = 1 SplashTextOn("This is a test", "Testing the splash screen" & $i, 160, 80, 10, 10) AdlibEnable("Adlib") MsgBox(0, "This is a test", "Testing testing 1,2,3") ;sleep(3000) Func Adlib() ControlSetText("This is a test", "", "Static1", "Testing the splash screen" & $i) $i = $i + 1 EndFunc Edited May 23, 2005 by MikeOsdx Link to comment Share on other sites More sharing options...
herewasplato Posted May 23, 2005 Share Posted May 23, 2005 ...will the function AdlibEnable("myadlib"), below, work:<{POST_SNAPBACK}>It depends on your definition of "work".As currently written:The app that you are testing (test-app) generates an error message.The script above (adlib-code) "sees" that error and pops up a msgbox.The test-app gens a second error message.The adlib-code will not see it because it has halted on the msgbox.**I've not tested this. Both gafrost and I think that the adlib-code will wait for the message box to be closed.later [size="1"][font="Arial"].[u].[/u][/font][/size] 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