SwordHunter4Ever Posted March 28, 2009 Share Posted March 28, 2009 Hey guys, my problem is that I have a script which I've made to interact with another program. However sometimes the other program crashes. If the other program crashes I need the script to stop what its doing and not attempt to keep interacting with the other program. When the other program crashes a warning window comes up, however it doesn't become the active window. It instead sits in the background, and the window name is "Program Error Manager". Is there any way to write a script that will detect if another window is opened by the title "Program Erorr Manager" and if so can it stop my script from continuing to run? ALSO since this error can happen at anytime is there a way to make the script check constantly (lets say once every 1000miliseconds) for the new windows? Thanks for your help ahead of time. Link to comment Share on other sites More sharing options...
GEOSoft Posted March 28, 2009 Share Posted March 28, 2009 Look at WinExists() It doesn't care if the window is active or not George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
SwordHunter4Ever Posted March 28, 2009 Author Share Posted March 28, 2009 (edited) Look at WinExists() It doesn't care if the window is active or notAlright I found this, If WinExists("Untitled -") Then MsgBox(0, "", "Window exists") EndIf and I made it into this, If WinExists("Program Error Manager") Then Sleep (2147483647) EndIf Is there a way to get it to check every second? while my script is running? Also I don't know how to command a script to end... I've never needed to before. I've always just let them run until they were over. Is there a simple command for kililng/stopping/shutting off the script? Edited March 28, 2009 by SwordHunter4Ever Link to comment Share on other sites More sharing options...
BinaryBrother Posted March 28, 2009 Share Posted March 28, 2009 Throw this in a loop... If WinExists("Program Manager Error") Then ProcessClose("Script.exe") ProcessClose("CrashedScript.exe") EndIfoÝ÷ Øw«z+C¡ûol×Ã÷±jjex§¦)æwb*.ë-Á©í¶ZºÇê-êìr¸©¶ì¢g)५,jö«¦åz)íéh¢§uÆ¥+KGºÚ"µÍYÚ[^ÝÊ ][ÝÔÙÜ[HX[YÙÜ][ÝÊH[ ÌÍÐÜÚHYB[YY ÌÍÐÜÚHYH[ÛY Ì B[Y Hope this helps... SIGNATURE_0X800007D NOT FOUND Link to comment Share on other sites More sharing options...
Marlo Posted March 28, 2009 Share Posted March 28, 2009 the Exit() command will end the script execution. Also if your program is "constantly running" then it must have a loop somewhere. Try inserting your code into the loop. Or take a look at the AdLibEnable() function. Click here for the best AutoIt help possible.Currently Working on: Autoit RAT Link to comment Share on other sites More sharing options...
SwordHunter4Ever Posted March 28, 2009 Author Share Posted March 28, 2009 (edited) Throw this in a loop... If WinExists("Program Manager Error") Then ProcessClose("Script.exe") ProcessClose("CrashedScript.exe") EndIfƒoÝŠ÷ Øw«z+C’¡ûol‰×šÃ÷±jjex§ž¦)æŠwb*.Žë-Á©í¶ŠZºÇ…ê-…êìr¸©¶Šì¢g†)५,jö«‰¦åz)í…éh¢–§uÆ¥–+KŠGšºÚ"µÍ’YˆÚ[‘^ÝÊ œ][ÝÔ›Ùܘ[HX[˜YÙˆœ›Ü‰œ][ÝÊH[‚ˆ ˆÌÍŽÐܘÚHYB‘[™Y‚’Yˆ ˆÌÍŽÐܘÚHYH[‚ˆÛY Ì B‘[™Y Hope this helps... So I would use While If WinExists("Program Manager Error") Then ProcessClose("Script.exe") ProcessClose("CrashedScript.exe") EndIf Wend At the start of my script? This would make my script look something like the following: HotkeySet("{HOME}","_end") Func _end() Exit 0 EndFunc WinMinimizeAll() While If WinExists("Program Manager Error") Then ProcessClose("Script.exe") ProcessClose("CrashedScript.exe") EndIf Wend $Amount = 0 Do BIG LONG SCRIPT HERE $Amount = $Amount + 1 Until $Amount = 1000 Exit Would that start the loop and then continue on to do the rest of my script in the DO/UNTIL tags? Also the start of the script is just a personal method of controlling the script, you can ignore that part I know its really strange x_X Also if your program is "constantly running" then it must have a loop somewhere. Try inserting your code into the loop. Or take a look at the AdLibEnable() function. It does have a DO/UNTIL statement in it (which is a loop) however I need it to check during that whole loop, not just at the start, middle or end (and I don't want to have to paste it in after every line). Edited March 28, 2009 by SwordHunter4Ever Link to comment Share on other sites More sharing options...
BinaryBrother Posted March 28, 2009 Share Posted March 28, 2009 Use "AdlibEnable" <--- SIGNATURE_0X800007D NOT FOUND Link to comment Share on other sites More sharing options...
SwordHunter4Ever Posted March 28, 2009 Author Share Posted March 28, 2009 (edited) HotkeySet("{HOME}","_end") Func _end() Exit 0 EndFunc WinMinimizeAll() AdlibEnable("ErrorCheck") Func ErrorCheck() If WinActive("Program ManagerError") Then ProcessClose("Script.exe") ProcessClose("CrashedScript.exe") EndIf EndFunc $Amount = 0 Do BIG LONG SCRIPT HERE $Amount = $Amount + 1 Until $Amount = 1000 Exit So like that? I tested it with this, AdlibEnable("ErrorCheck") Func ErrorCheck() If WinActive("Untitled - Notepad") Then Exit EndIf EndFunc and when I opened a notepad document it quit so it seems to be working. Thank you guys!!! Edited March 28, 2009 by SwordHunter4Ever 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