nomisre Posted November 30, 2015 Share Posted November 30, 2015 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 tab3. Switch to second tab after 60 seconds4. Switch to third tab after 60 seconds5. Switch to first tab after 60 secondsetc etcFor 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 tabSleep(60000)ControlSend("[CLASS:IEFrame]", "", "", "{^2}") ;next tabSleep(60000)ControlSend("[CLASS:IEFrame]", "", "", "{^3}") ;next tabSleep(60000); LoopWhile 1 Sleep(1)WEndCan somebody help me with the code? I am really new to scripting.Thanks in advance Link to comment Share on other sites More sharing options...
nomisre Posted November 30, 2015 Author Share Posted November 30, 2015 (edited) Edited November 30, 2015 by nomisre Link to comment Share on other sites More sharing options...
nomisre Posted November 30, 2015 Author Share Posted November 30, 2015 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, etcSend("^{TAB}")Sleep(5000)Send("^{TAB}")Sleep(5000)Send("^{TAB}")Sleep(5000)Send("^{TAB}")Sleep(5000); LoopWhile 1 Sleep(1)WEnd Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted November 30, 2015 Moderators Share Posted November 30, 2015 @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 More sharing options...
nomisre Posted November 30, 2015 Author Share Posted November 30, 2015 @nomisre, put all the sends and sleeps inside your while loop, in place of the Sleep(1).Thanks! Link to comment Share on other sites More sharing options...
ViciousXUSMC Posted November 30, 2015 Share Posted November 30, 2015 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 More sharing options...
nomisre Posted December 2, 2015 Author Share Posted December 2, 2015 (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 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 December 2, 2015 by nomisre Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now