Jump to content

Close IE window but leave one ?


Recommended Posts

might be easier to use a free one, but basically you can set autoit to loop and look for any window criteria you specify, and close those, but I would suggest Firefox. :D

http://www.mozilla.org/products/firefox/

Free browser that has a lot of nice features, (one being popup stoper.) Some others would suggest Opera.

while 1
if winexists("Buy crap from me","") then winclose("Buy crap from me","") 
if winexists("Buy now","") then winclose("Buy now","") 
sleep(1)
wend

...edit hmm, interesting approach Larry, I might try that.

Edited by scriptkitty

AutoIt3, the MACGYVER Pocket Knife for computers.

Link to comment
Share on other sites

I use firefox , this is for the nieces computer I just built for them and it has IE on it .

I just want it to kill any Internet Explore window that opens after the first one is open and if they need more to open thet can just click on it to pause it .

Link to comment
Share on other sites

I use firefox , this is for the nieces computer I just built for them and it has IE on it .

I just want it to kill any Internet Explore window that opens after the first one is open and if they need more to open thet can just click on it to pause it .

I'd suggest the google toolbar in that case, simple and works well (as well as a handy way to google)

"I'm not even supposed to be here today!" -Dante (Hicks)

Link to comment
Share on other sites

I am using "google toolbar" + "spy-bot search and destroy", then occasional Adaware.

Lar.

thank god for those tools, sometimes, when the spyware gets in deep, you need "hijack this" as well... spent four hours yesterday with a PC that was dying of the crap...

"I'm not even supposed to be here today!" -Dante (Hicks)

Link to comment
Share on other sites

Run("C:\Program Files\Internet Explorer\IEXPLORE.EXE")
sleep(2000)
Opt("WinTitleMatchMode",2)
$hWnd =WinGetHandle("Microsoft Internet Explorer")
Opt("WinTitleMatchMode",4)
While 1
Opt("WinTitleMatchMode",2)
$x = WinGetHandle("Microsoft Internet Explorer")
Opt("WinTitleMatchMode",4)
    If $x<>$hWnd Then   winclose("handle="&$x)
    sleep(10)
    If NOT winexists("handle="&$hWnd) Then exit
Wend

Popup stopper from Larry code.

AutoIt3, the MACGYVER Pocket Knife for computers.

Link to comment
Share on other sites

every time you click on a page, it has the chance to update the full title Larry, so if it was at the wrong milisecond, you might close it.

While WinExists($hWnd)

    WinSetTitle($hWnd,"",StringReplace(WinGetTitle($hWnd),"plorer","pl0rer"))

    Opt("WinTitleMatchMode",2); lets just say right now the web page updated title

    If WinExists("Microsoft Internet Explorer") Then

      WinClose("Microsoft Internet Explorer")

    EndIf

try WinSetTitle("Microsoft Internet Explorer","","bob") and click on a page, you will notice the full titlebar is back.

My version of your code works, but the popup would have to get focus, it wouldn't work well with backround ones.

Run("C:\Program Files\Internet Explorer\IEXPLORE.EXE")
sleep(2000)
Opt("WinTitleMatchMode",2)
$hWnd =WinGetHandle("Microsoft Internet Explorer")
Opt("WinTitleMatchMode",4)
While 1
Opt("WinTitleMatchMode",2)
$x = WinGetHandle("Microsoft Internet Explorer")
Opt("WinTitleMatchMode",4)
If $x<>$hWnd Then winclose("handle="&$x)
sleep(10)
If NOT winexists("handle="&$hWnd) Then exitloop
Wend
while winexists("Microsoft Internet Explorer"); close backround ones.
winclose("Microsoft Internet Explorer")
wend
Edited by scriptkitty

AutoIt3, the MACGYVER Pocket Knife for computers.

Link to comment
Share on other sites

That one larry does not work to good . it opens it and when you click on the back button it closes the window ? ( i was at a porn site to test popups , really I was . lol )

Link to comment
Share on other sites

Sheesh, why do you hate my code so much?

Code explained.

Run("C:\Program Files\Internet Explorer\IEXPLORE.EXE")
sleep(2000)
Opt("WinTitleMatchMode",2)
$hWnd =WinGetHandle("Microsoft Internet Explorer"); get good handle
While 1; loop
Opt("WinTitleMatchMode",2) 
$x = WinGetHandle("Microsoft Internet Explorer"); check for other handle
Opt("WinTitleMatchMode",4)
If $x<>$hWnd Then winclose("handle="&$x); close if not my handle
sleep(10)
If NOT winexists("handle="&$hWnd) Then exitloop; stop if original is gone 
Wend
while winexists("Microsoft Internet Explorer"); close backround ones.
winclose("Microsoft Internet Explorer")
wend

..edit my question would be, can you use both

WinExists("Microsoft Internet Explorer") And _

"handle=" & WinGetHandle("Microsoft Internet Explorer") <> $hWnd under Opt("WinTitleMatchMode",4)??

Edited by scriptkitty

AutoIt3, the MACGYVER Pocket Knife for computers.

Link to comment
Share on other sites

Sheesh, why do you hate my code so much?

Code explained.

Run("C:\Program Files\Internet Explorer\IEXPLORE.EXE")
sleep(2000)
Opt("WinTitleMatchMode",2)
$hWnd =WinGetHandle("Microsoft Internet Explorer"); get good handle
While 1; loop
Opt("WinTitleMatchMode",2) 
$x = WinGetHandle("Microsoft Internet Explorer"); check for other handle
Opt("WinTitleMatchMode",4)
If $x<>$hWnd Then winclose("handle="&$x); close if not my handle
sleep(10)
If NOT winexists("handle="&$hWnd) Then exitloop; stop if original is gone 
Wend
while winexists("Microsoft Internet Explorer"); close backround ones.
winclose("Microsoft Internet Explorer")
wend
I like it and it worked great .. :D
Link to comment
Share on other sites

I tested mine, it works OK. Adds and spyware do many more evil things than pop up windows though, so I still suggest some other program, like say google or such. This is more of an example of showing cool things you can do with AutoIt than a perfect solution.

Webpages can add tracking cookies, lock up your mouse, change your homepage, and many other more sinister things.

It is nice to know you can build a fire on your own, but after that, I grab a lighter or matches.

AutoIt3, the MACGYVER Pocket Knife for computers.

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