Tr10 Posted February 16, 2008 Share Posted February 16, 2008 What I would like to accomplish is this:I run a program that often crashes, when it does crash it will pop up with a window titled "StealthBot"I wrote this autoit script to wait for that window title exactly.but for some reason, it will always find the program even when its window title contains stealthbot and try to execute the commands.Opt("WinTitleMatchMode", 3) While Winwait ( "StealthBot" ) sleep (1000) Winactivate ( "StealthBot" ) sleep (1000) send ("{enter}") sleep (500) run ( "C:\Program Files\StealthBot\old\sb.exe") sleep (10000) Send ( "{alt}") Sleep (300) Send ( "s" ) Sleep (300) Send ("s") WEndThe other window title is [eDDma, online in channel Clan GM] - Stealthbot v2.6 Revision 3Here is a screenshot of the window I am looking for.If anyone can think of a more productive way to do this, it would be fantastic.Thank you Any questions or input you have will be helpful. Link to comment Share on other sites More sharing options...
rasim Posted February 16, 2008 Share Posted February 16, 2008 Hi! Wrong algorithm, try this: Opt("WinTitleMatchMode", 3) Winwait ( "StealthBot" ) While WinExists("StealthBot") sleep (1000) Winactivate ( "StealthBot" ) sleep (1000) send ("{enter}") sleep (500) run("C:\Program Files\StealthBot\old\sb.exe") sleep (10000) Send ( "{alt}") Sleep (300) Send ( "s" ) Sleep (300) Send ("s") WEnd Link to comment Share on other sites More sharing options...
JerryD Posted February 16, 2008 Share Posted February 16, 2008 How aboutHotKeySet ( '{F9}', 'MyExit' ) While 1 ControlClick ( 'StealthBot', '', 'OK' ) Sleep ( 250 ) WEnd Func MyExit() Exit(0) EndFunc I suppose you could and a If WinExists in there, but this doesn't seem to tax the system at all, so why bother? Link to comment Share on other sites More sharing options...
Tr10 Posted February 16, 2008 Author Share Posted February 16, 2008 Hi! Wrong algorithm, try this: Opt("WinTitleMatchMode", 3) Winwait ( "StealthBot" ) While WinExists("StealthBot") sleep (1000) Winactivate ( "StealthBot" ) sleep (1000) send ("{enter}") sleep (500) run("C:\Program Files\StealthBot\old\sb.exe") sleep (10000) Send ( "{alt}") Sleep (300) Send ( "s" ) Sleep (300) Send ("s") WEnd Thanks for fixing my error But for some reason, it keeps finding the other window instead of the one that reads Stealthbot. The error box doesn't seem to have its own window, it seems that it is somehow a part of the already existing window Link to comment Share on other sites More sharing options...
FreeFry Posted February 16, 2008 Share Posted February 16, 2008 (edited) I guess this would do the trick? Opt("WinTitleMatchMode", 4) While 1 If WinExists("[TITLE:StealthBot]", "Run-time error") Then WinClose("[LAST]") EndIf Sleep(250) WEnd Edited February 16, 2008 by FreeFry Link to comment Share on other sites More sharing options...
Tr10 Posted February 16, 2008 Author Share Posted February 16, 2008 I guess this would do the trick? Opt("WinTitleMatchMode", 4) While 1 If WinExists("[TITLE:StealthBot]", "Run-time error") Then WinClose("[LAST]") EndIf Sleep(250) WEnd I will give it a try and get back to you I like the angle that you approached this at, I would have never thought to do that Thank you Anyone else have any ideas? Link to comment Share on other sites More sharing options...
martin Posted February 16, 2008 Share Posted February 16, 2008 I will give it a try and get back to you I like the angle that you approached this at, I would have never thought to do that Thank you Anyone else have any ideas?Maybe instead of While Winwait ( "StealthBot" )tryWhile WinwaitActive ( "StealthBot" ) Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
FreeFry Posted February 17, 2008 Share Posted February 17, 2008 I will give it a try and get back to you I like the angle that you approached this at, I would have never thought to do that Thank you Anyone else have any ideas?I guess you're trying to make an auto-restarter application right? So if the StealthBot app crashes, it will 'handle' the crash message, and restart it? Link to comment Share on other sites More sharing options...
Tr10 Posted February 17, 2008 Author Share Posted February 17, 2008 Exactly Your script has worked like a charm so far I'm gonna try running it over night and I will definitely get back to you. I thank you all for your time and patience through this process Link to comment Share on other sites More sharing options...
FreeFry Posted February 17, 2008 Share Posted February 17, 2008 Great. It should handle all run-time errors(atleast the ones that pops up a msg box with that title and text), but for more 'critical' errors, you might need to add more 'handling'. lol Link to comment Share on other sites More sharing options...
Tr10 Posted February 18, 2008 Author Share Posted February 18, 2008 Great.It should handle all run-time errors(atleast the ones that pops up a msg box with that title and text), but for more 'critical' errors, you might need to add more 'handling'. lolYou're amazing, that worked perfectly, I assume the same script will work as long as I change the optional text it searches for?I appreciate all the time and effort you all put into helping me with this annoying problem Thanks again <3 Link to comment Share on other sites More sharing options...
FreeFry Posted February 18, 2008 Share Posted February 18, 2008 (edited) You're amazing, that worked perfectly, I assume the same script will work as long as I change the optional text it searches for? I appreciate all the time and effort you all put into helping me with this annoying problem Thanks again <3 Always glad to help. If you wan't to catch more error messages(named otherwise) one approach would be to do like this: Opt("WinTitleMatchMode", 4) Dim $aErrorMessages[2][2] ; create our array that will hold our window titles and texts ; $aErrorMessages[x][0] will be window title to catch ; $aErrorMessages[x][1] will be window text to catch $aErrorMessages[0][0] = "[TITLE:StealthBot]" ; title of window #1 $aErrorMessages[0][1] = "Run-time error" ; text of window #1 $aErrorMessages[1][0] = "[TITLE:BoobBot]" ; title of window #2 (hihi) $aErrorMessages[1][1] = "Mega error" ; text of window #2 While 1 For $i = 0 To UBound($aErrorMessages)-1 ; loop through the array If WinExists($aErrorMessages[$i][0], $aErrorMessages[$i][1]) Then ; if the window exist WinClose($aErrorMessages[$i][0], $aErrorMessages[$i][1]) ; close the window ; perhaps do something more here too? restarting it perhaps :) EndIf Sleep(250) ; sleep 250 ms to avoid killing that workhorse of yours ;P Next WEnd Edited February 18, 2008 by FreeFry 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