Jump to content

Recommended Posts

Posted

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

Posted

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)

 

Posted (edited)

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

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
  • Recently Browsing   0 members

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