NELyon Posted June 9, 2006 Posted June 9, 2006 HotKeySet("z","KillPopups") Func KillPopups() If WinExists("- Microsoft Internet Explorer") Then WinKill("- Microsoft Internet Explorer") EndFunc I just want to use this to close all IE windows when i press "z" but the script terminates inself as soon as it is run. can anyone help?
Moderators SmOke_N Posted June 9, 2006 Moderators Posted June 9, 2006 HotKeySet("z","KillPopups") Func KillPopups() If WinExists("- Microsoft Internet Explorer") Then WinKill("- Microsoft Internet Explorer") EndFunc Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
NELyon Posted June 9, 2006 Author Posted June 9, 2006 That works but it doesen't keep the program open long enough to be of use.
sd333221 Posted June 9, 2006 Posted June 9, 2006 (edited) HotKeySet("z","KillPopups") While 1 Sleep(300) Wend Func KillPopups() If WinExists("- Microsoft Internet Explorer") Then WinKill("- Microsoft Internet Explorer") EndFunc try this Edited June 9, 2006 by sd333221
Moderators SmOke_N Posted June 9, 2006 Moderators Posted June 9, 2006 I had no idea that was your "whole" script, yes, sd333221 hit the nail on the head, you must at least have a loop to hold it doing something until you hit 'z' Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
elgabionline Posted June 9, 2006 Posted June 9, 2006 I just want to use this to close all IE windows when i press "z" but the script terminates inself as soon as it is run. can anyone help? You should insert a loop: HotKeySet("z","KillPopups") while 1 sleep (1) wend Func KillPopups() If WinExists("- Microsoft Internet Explorer") Then WinKill("- Microsoft Internet Explorer") EndFunc
sd333221 Posted June 9, 2006 Posted June 9, 2006 (edited) You should insert a loop: HotKeySet("z","KillPopups") while 1 sleep (1) wend Func KillPopups() If WinExists("- Microsoft Internet Explorer") Then WinKill("- Microsoft Internet Explorer") EndFunc please remember that a sleep(1) could cause a 100% cpu usage very fast. Take sleep(300) Edited June 9, 2006 by sd333221
NELyon Posted June 9, 2006 Author Posted June 9, 2006 ...thats a pretty small loop... testing... why won't it work i wonder...
sd333221 Posted June 9, 2006 Posted June 9, 2006 ...thats a pretty small loop... testing...why won't it work i wonder...because without a loop, it only checks 1 time if the hotkey is pressed and if not,the program is finished and it shuts down.the loop holds the program running and waiting for the hotkey to be pressed
NELyon Posted June 9, 2006 Author Posted June 9, 2006 (edited) yeah... ok i am getting the program to stay open. but it still wont kill the IE windows. here's the whole code i'm using: while 1 sleep (300) wend HotKeySet("z","KillPopups") Func KillPopups() If ProcessExists('iexplore.exe') Then ProcessClose('iexplore.exe') EndFunc Edited June 9, 2006 by codemyster
elgabionline Posted June 9, 2006 Posted June 9, 2006 yeah... ok i am getting the program to stay open. but it still wont kill the IE windows. here's the whole code i'm using: while 1 sleep (300) wend HotKeySet("z","KillPopups") Func KillPopups() If ProcessExists('iexplore.exe') Then ProcessClose('iexplore.exe') EndFunc Put hotkeyset on top. That shoul be work....
bucky002 Posted June 9, 2006 Posted June 9, 2006 (edited) You could probably do this HotKeySet("z","KillPopups") while 1 sleep (300) wend Func KillPopups() If ProcessExists('iexplore.exe') Then ProcessClose('iexplore.exe') Endif EndFuncoÝ÷ Ù8b²ÞÂ䱫¢+Ù!½Ñ-åMÐ ÅÕ½ÐíèÅÕ½Ðì°ÅÕ½Ðí-¥±±A½ÁÕÁÌÅÕ½Ðì¤)=ÁÐ ÅÕ½Ðí]¥¹Q¥Ñ±5Ñ¡5½ÅÕ½Ðì°È¤)]¡¥±Ä)M±À ÌÀÀ¤)]¹()Õ¹-¥±±A½ÁÕÁÌ ¤)%]¥¹á¥ÍÑÌ ÅÕ½Ðì´5¥É½Í½Ð%¹ÑɹÐáÁ±½ÉÈÅÕ½Ðì¤Q¡¸(%]¥¹ ±½Í ÅÕ½Ðì´5¥É½Í½Ð%¹ÑɹÐáÁ±½ÉÈÅÕ½Ðì¤)¹%$)¹Õ¹ Note: You were missing "EndIF" in both of them Edited June 9, 2006 by bucky002
Moderators SmOke_N Posted June 9, 2006 Moderators Posted June 9, 2006 Nope. still doesn't work.The way you have it set up, looks like it will only close 1 window at a time. Why not just use the ProcessExists()/ProcessClose() option I said in that function? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
elgabionline Posted June 9, 2006 Posted June 9, 2006 Nope. still doesn't work. Sure you are using a Internet Explorer window, not Mozilla or Opera? Then try with this: #include <misc.au3> while 1 sleep (300) if _ispressed ("5A") then KillPopups () wend Func KillPopups() If ProcessExists('iexplore.exe') Then ProcessClose('iexplore.exe') EndFunc
Moderators SmOke_N Posted June 9, 2006 Moderators Posted June 9, 2006 I am using the ProcessExists thingThis worked:HotKeySet("z","KillPopups") While 1 Sleep(1000) WEnd Func KillPopups() If ProcessExists('iexplore.exe') Then Do ProcessClose('iexplore.exe') Until Not ProcessExists('iexplore.exe') EndIf EndFunc Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
bucky002 Posted June 9, 2006 Posted June 9, 2006 This will close them all. HotKeySet("z","KillPopups") while 1 sleep (300) wend Func KillPopups() While 1 If ProcessExists('iexplore.exe') Then ProcessClose('iexplore.exe') Endif WEnd EndFunc
Moderators SmOke_N Posted June 9, 2006 Moderators Posted June 9, 2006 (edited) This will close them all. HotKeySet("z","KillPopups") while 1 sleep (300) wend Func KillPopups() While 1 If ProcessExists('iexplore.exe') Then ProcessClose('iexplore.exe') Endif WEnd EndFuncBucky, with that example you never leave your loop..While ProcessExists('iexplore.exe') ProcessClose('iexplore.exe') WEndIs more like it I think Edit: Or the example I gave with the Do/Until Edited June 9, 2006 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
NELyon Posted June 9, 2006 Author Posted June 9, 2006 This worked:HotKeySet("z","KillPopups") While 1 Sleep(1000) WEnd Func KillPopups() If ProcessExists('iexplore.exe') Then Do ProcessClose('iexplore.exe') Until Not ProcessExists('iexplore.exe') EndIf EndFuncOh my gosh thank you! That works perfectly!
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