Jump to content

Script Doesn't stay open long enough to use!


Recommended Posts

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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

  • Moderators

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.

Link to comment
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
Link to comment
Share on other sites

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
Link to comment
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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

  • Moderators

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.

Link to comment
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
Link to comment
Share on other sites

  • Moderators

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

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.

Link to comment
Share on other sites

  • Moderators

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

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.

Link to comment
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!
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...