nicko79 Posted May 19, 2016 Share Posted May 19, 2016 Hello All, Thanks for the help in advance. I have never used Auto It before so am trying to throw a script together for the first time. I really have no true idea how the While 1 and Wend statements work so they are probably a mess. Essentially I want 1 script to constantly look for Windows with certain titles. If any of those titles pop up I want it to kill the window. I got it to work with 1 window but cannot figure out how to make it constantly search for a bunch of different windows. I may want it to look for 10 different window titles and then start over Here is my example: HotKeySet("{ESC}", "_Terminate") Popups() Func Popups() While 1 If WinActive("[Title:Example 1]") Then WinKill ("[Title:Example 1]") EndIf While 1 If WinActive("[Title:Example 2]") Then WinKill ("[Title:Example 2]") EndIf Sleep(10000) WEnd EndFunc ;==>Popups Func _Terminate() Exit EndFunc ;==>_Terminate Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted May 19, 2016 Moderators Share Posted May 19, 2016 (edited) Hi, @nicko79 welcome to the forum. In essence, While 1 is the same as saying While 1 = 1; it just creates a continual loop that goes on forever until you break out of it. As regards the code inside your While loop, I would try something like this: Func Popups() While 1 If WinActive("[Title:Example 1]") Then WinKill ("[Title:Example 1]") ElseIf WinActive("[Title:Example 2]") Then WinKill ("[Title:Example 2]") EndIf Sleep(100) WEnd EndFunc ;==>Popups Notice the much smaller Sleep period. All you're doing is trying to give the CPU a chance to breathe; no need to put in a long sleep session. You might also look at WinClose over WinKill, to see if you can get by with the more graceful function. If you have any questions, please don't hesitate to ask. Edited May 19, 2016 by JLogan3o13 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
nicko79 Posted May 19, 2016 Author Share Posted May 19, 2016 Works perfectly. Thank you. Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted May 19, 2016 Moderators Share Posted May 19, 2016 Glad to help "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! 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