willwatters Posted May 11, 2005 Share Posted May 11, 2005 Is the following code efficient to detect if an unexpected error occurs. If not please recommend any amendments. I'm using autoit to test applications, but need to detect if an unexpected error occurrs when i'm testing this automatically. ;/* check for unforeseen errors every 250 MS (i.e. checks for an error window to pop up unpredictably, etc) AdlibEnable("myadlib") Func myadlib() If WinActive("Error") Then _MyLog($Pre, "16", "CLMS Remote Access", "Unexpected error occurred", "") WinClose("Flourish - Clms [ Multiple Setup Support ]") WinClose("Flourish Client Login") WinClose("CLMS - Northbook Technology - Magee Campus") Exit EndIf EndFunc Does the WinActive("Error") command only detect windows that say 'Error'. If so I need code to detect other error messages or errors that might vary in name, than 'Error'. Thanks Link to comment Share on other sites More sharing options...
MHz Posted May 11, 2005 Share Posted May 11, 2005 Other windows with "Error" ? Use Opt("WinTitleMatchMode", 2) at the top of your script for substring title search Link to comment Share on other sites More sharing options...
Helge Posted May 11, 2005 Share Posted May 11, 2005 You could add the lines to the top of your code : Opt("WinTitleMatchMode",2) Opt("WinWaitDelay",10) You could maybe be a little more specific on the title (or text) of the error-msgbox if that is possible, since using the first line of code above and use only "Error" as title can result in unwanted..results. Link to comment Share on other sites More sharing options...
willwatters Posted May 12, 2005 Author Share Posted May 12, 2005 Where abouts do I put this in my code: AdlibEnable("myadlib") Func myadlib() If WinActive("Error") Then _MyLog($Pre, "16", "CLMS Remote Access", "Unexpected error occurred", "") WinClose("Flourish - Clms [ Multiple Setup Support ]") WinClose("Flourish Client Login") WinClose("CLMS - Northbook Technology - Magee Campus") Exit EndIf EndFunc Link to comment Share on other sites More sharing options...
MHz Posted May 12, 2005 Share Posted May 12, 2005 The function can be placed at the bottom of your script, out of the way. The AdlibEnable() should be placed in the script when you want to start scanning for error windows. Link to comment Share on other sites More sharing options...
willwatters Posted May 12, 2005 Author Share Posted May 12, 2005 So is this the correct place to insert the new code: AdlibEnable("myadlib") Func myadlib() Opt("WinTitleMatchMode",2) Opt("WinWaitDelay",10) If WinActive("Error") Then _MyLog($Pre, "16", "CLMS Remote Access", "Unexpected error occurred", "") WinClose("Flourish - Clms [ Multiple Setup Support ]") WinClose("Flourish Client Login") WinClose("CLMS - Northbook Technology - Magee Campus") Exit EndIf EndFunc Link to comment Share on other sites More sharing options...
willwatters Posted May 12, 2005 Author Share Posted May 12, 2005 You could add the lines to the top of your code :Opt("WinTitleMatchMode",2) Opt("WinWaitDelay",10)You could maybe be a little more specific on the title (or text) of the error-msgboxif that is possible, since using the first line of code above and use only "Error" astitle can result in unwanted..results.<{POST_SNAPBACK}>what title or text do you recommend on using then? 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