Jump to content

Switch between IE tabs every 60 seconds


nomisre
 Share

Recommended Posts

Hello,

We have a customer that wants to automatically switch between a few tabs in IE. This process has to loop infinitely.

My goal is: 

1. Open IE with three tabs (I have this part working)
2. Begin on first tab
3. Switch to second tab after 60 seconds
4. Switch to third tab after 60 seconds
5. Switch to first tab after 60 seconds
etc etc

For now I have this:

#include <IE.au3>

; Script Start - Add your code below here

$oIE = _IECreate("www.google.nl")
__IENavigate($oIE, "http://www.nu.nl/", 0, 0x800)
__IENavigate($oIE, "http://www.telegraaf.nl/", 0, 0x800)

ControlSend("[CLASS:IEFrame]", "", "", "{^1}") ;next tab
Sleep(60000)
ControlSend("[CLASS:IEFrame]", "", "", "{^2}") ;next tab
Sleep(60000)
ControlSend("[CLASS:IEFrame]", "", "", "{^3}") ;next tab
Sleep(60000)

; Loop

While 1
    Sleep(1)
WEnd


Can somebody help me with the code? I am really new to scripting.

Thanks in advance

Link to comment
Share on other sites

It now switches to the next tab, but how can I make it loop forever?

#include <IE.au3>

; Opens IE with three tabs

$oIE = _IECreate("www.google.nl")
__IENavigate($oIE, "http://www.nu.nl/", 0, 0x800)
__IENavigate($oIE, "http://www.telegraaf.nl/", 0, 0x800)

; Next tab, next tab, etc

Send("^{TAB}")
Sleep(5000)
Send("^{TAB}")
Sleep(5000)
Send("^{TAB}")
Sleep(5000)
Send("^{TAB}")
Sleep(5000)

; Loop

While 1
    Sleep(1)
WEnd

Link to comment
Share on other sites

  • Moderators

@nomisre, put all the sends and sleeps inside your while loop, in place of the Sleep(1).

"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

And of course since it is looping you only need 1 of them.

 

#include <IE.au3>

; Opens IE with three tabs

$oIE = _IECreate("www.google.nl")
__IENavigate($oIE, "http://www.nu.nl/", 0, 0x800)
__IENavigate($oIE, "http://www.telegraaf.nl/", 0, 0x800)


; Tab Loop

While 1
   Sleep(5000) 
   Send("^{TAB}")
WEnd

 

I assume this runs on a display computer and nobody is touching the mouse/keyboard but you might want to put like a WinActivate() or something in the loop just to ensure it stays in focus, and perhaps have it exit the loop when you close IE.

#include <IE.au3>

; Opens IE with three tabs

$oIE = _IECreate("www.google.nl")
$IEhwnd = _IEPropertyGet($oIE, "hwnd")
__IENavigate($oIE, "http://www.nu.nl/", 0, 0x800)
__IENavigate($oIE, "http://www.telegraaf.nl/", 0, 0x800)


; Tab Loop

While 1
If WinExists($IEhwnd) Then 
    WinActivate($IEhwnd)
Else
    ExitLoop
EndIf
    
Sleep(5000) 
Send("^{TAB}")
WEnd

_IEQuit($oIE)

 

Link to comment
Share on other sites

And of course since it is looping you only need 1 of them.

 

#include <IE.au3>

; Opens IE with three tabs

$oIE = _IECreate("www.google.nl")
__IENavigate($oIE, "http://www.nu.nl/", 0, 0x800)
__IENavigate($oIE, "http://www.telegraaf.nl/", 0, 0x800)


; Tab Loop

While 1
   Sleep(5000) 
   Send("^{TAB}")
WEnd

 

I assume this runs on a display computer and nobody is touching the mouse/keyboard but you might want to put like a WinActivate() or something in the loop just to ensure it stays in focus, and perhaps have it exit the loop when you close IE.

#include <IE.au3>

; Opens IE with three tabs

$oIE = _IECreate("www.google.nl")
$IEhwnd = _IEPropertyGet($oIE, "hwnd")
__IENavigate($oIE, "http://www.nu.nl/", 0, 0x800)
__IENavigate($oIE, "http://www.telegraaf.nl/", 0, 0x800)


; Tab Loop

While 1
If WinExists($IEhwnd) Then 
    WinActivate($IEhwnd)
Else
    ExitLoop
EndIf
    
Sleep(5000) 
Send("^{TAB}")
WEnd

_IEQuit($oIE)

 

Thanks, this is exactly what I need. I was already wondering how to stop the script :P

The browser window also needs to be maximized. I believe I have to use @SW_MAXIMIZE, but I don't understand how and where.

Edit: got it working by myself :)
 

Edited by nomisre
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...