Sign in to follow this  
Followers 0
NELyon

Script Doesn't stay open long enough to use!

25 posts in this topic

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?

Share this post


Link to post
Share on other sites



HotKeySet("z","KillPopups")
Func KillPopups()
If WinExists("- Microsoft Internet Explorer") Then WinKill("- Microsoft Internet Explorer")
EndFunc

[center]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.[/center]

Share this post


Link to post
Share on other sites

That works but it doesen't keep the program open long enough to be of use.

Share this post


Link to post
Share on other sites

#4 ·  Posted (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 by sd333221

Share this post


Link to post
Share on other sites

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'


[center]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.[/center]

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

#7 ·  Posted (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)
:D Edited by sd333221

Share this post


Link to post
Share on other sites

...thats a pretty small loop... testing...

why won't it work i wonder...

Share this post


Link to post
Share on other sites

...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 :D

Share this post


Link to post
Share on other sites

#10 ·  Posted (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 by codemyster

Share this post


Link to post
Share on other sites

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....

Share this post


Link to post
Share on other sites

Nope. still doesn't work.

Share this post


Link to post
Share on other sites

#13 ·  Posted (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 by bucky002

Share this post


Link to post
Share on other sites

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?

[center]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.[/center]

Share this post


Link to post
Share on other sites

I am using the ProcessExists thing

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

I am using the ProcessExists thing

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
EndFunc

[center]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.[/center]

Share this post


Link to post
Share on other sites

#19 ·  Posted (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
EndFunc
Bucky, with that example you never leave your loop..
While ProcessExists('iexplore.exe')
    ProcessClose('iexplore.exe')
WEnd
Is more like it I think :D

Edit:

Or the example I gave with the Do/Until

Edited by SmOke_N

[center]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.[/center]

Share this post


Link to post
Share on other sites

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
EndFunc
Oh my gosh thank you! That works perfectly!

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0