Jump to content
Sign in to follow this  
Remo1075

Auto IE refresh

Recommended Posts

Remo1075

Hi Guys

I have a useable script based on the one below for use on a ticket system that needs updating every 5 minutes. The only problem is, I want it to stop running when it cannot detect the window anymore. Say for instance when the window has been closed manually.

Hope you can help

Thanks in advance

#cs ----------------------------------------------------------------------------

AutoIt Version: 3.3.0.0

Author:

Script Version: 2.0.0.0

Script Function:

Template AutoIt script.

#ce ----------------------------------------------------------------------------

BlockInput(1)

ShellExecute(@ProgramFilesDir & "\Internet Explorer\IEXPLORE.EXE", "http://www.yahoo.co.uk")

sleep(4000)

Send("!d")

sleep(1000)

send("www.google.co.uk")

send("{enter}")

BlockInput(0)

$i = 0

While $i <= 10 ;refresh 10 times

Opt("WinTitleMatchMode", 3)

WinActivate("Google - Microsoft Internet Explorer")

WinWaitActive("Google - Microsoft Internet Explorer", "", 3)

Send("{F5}")

;If WinActive("Google - Microsoft Internet Explorer") = 1 then Send("{F5}") else

;If WinActive("Google - Microsoft Internet Explorer") = 0 then exit I would like to insert something like this, that exits out of the loop if say

someone closes the window

sleep(5000) ;wait 5 seconds before sending next F5

$i = $i + 1

wend

WinClose("Google - Microsoft Internet Explorer")

exit

Edited by Remo1075

Share this post


Link to post
Share on other sites
John117

Hi Guys

I have a useable script based on the one below for use on a ticket system that needs updating every 5 minutes. The only problem is, I want it to stop running when it cannot detect the window anymore. Say for instance when the window has been closed manually.

My suggestion, if you have time is to recode this. It is not that reliable. See the help functions in the help file for IE.

You will end up with something like . . .

#include <IE.au3.>
$oIE = _IECreate(http://www.yahoo.co.uk, 0, 1, 1, 1)
$begin = TimerInite()

While 1
     Sleep(1000)
     $dif = TimerDiff($begin)
     If $dif > (5 * 60 * 1000) Then
         $StillRunning  =  _IEAction($oIE, "refresh")
         If $StillRunning <> "1" then Exit
         $begin = TimerInite()
     EndIf
WEnd

Edit: I relly can spell! ;-)

Edited by John117

Share this post


Link to post
Share on other sites
Remo1075

Thanks for the quick response, I'll take a look and try figure out what you wrote. It looks a bit complicated for me. Was hoping for a solution with what I had. I know it's not that reliable but at least I understand it.

Thanks again.

My suggestion, if you have time is to recode this. It is not that reliable. See the help functions in the help file for IE.

You will end up with something like . . .

#include <IE.au3.>
$oIE = _IECreate(http://www.yahoo.co.uk, 0, 1, 1, 1)
$begin = TimerInite()

While 1
     Sleep(1000)
     $dif = TimerDiff($begin)
     If $dif > (5 * 60 * 1000) Then
         $StillRunning  =  _IEAction($oIE, "refresh")
         If $StillRunning <> "1" then Exit
         $begin = TimerInite()
     EndIf
WEnd

Edit: I relly can spell! ;-)

Share this post


Link to post
Share on other sites
John117

Sorry, what you had was awful! ;) -And far more complicated BTW ^_^

Break it down.

#include <IE.au3.> ;This is just an include . . . "that means its a function a smart member has made for our use!" -they are with the install.
$oIE = _IECreate(http://www.yahoo.co.uk, 0, 1, 1, 1) ;-this is a variable ($oIE) -good for recall later, and a function (IECreate) that a member made to open a webpage.
$begin = TimerInite() ;This is just a timer. Imagine starting a stop watch here. $begin is the name of the "stop watch"

While 1 ;While 1 just keeps on running.
     Sleep(1000) ;sleep for 1 second. (because you are waiting 5 min, what's a sec or two over 5 min -plus it takes less cpu.)
     $dif = TimerDiff($begin) ;$Dif is the time since you turned on the stop watch ($begin)
     If $dif > (5 * 60 * 1000) Then ;If it has been over 5 min (min * Sec * milsec)
         $StillRunning  =  _IEAction($oIE, "refresh") ;This is a variable and another function (See smart person ^^^) to preform an IE action "Refresh" -If it works, it returns "1". You can check for "1" by the value of the Variable. You call the $variable anything you want! :-)
         If $StillRunning <> "1" then Exit ;If the $variable is not "1" -then refresh didn't work! "you can't refresh something that's closed!!! :-) Then Exit!
         $begin = TimerInite() ; if it didn't exit then it must be open. So lets start the timer again! 5 min here we come! :-)
     EndIf ;stop $StillRunning test.
WEnd  ;Start over @ while 1

Edit: Did that help any? -Your post wasn't bad, just more complex, harder to control, and older method.

Edit: Try to avoid "Send" when you can. I am guessing it was sending the keystrokes when closed . . . no telling what was recieving them . . .

Edited by John117

Share this post


Link to post
Share on other sites
Remo1075

Fantastic, thanks alot

Edit: Try to avoid "Send" when you can. I am guessing it was sending the keystrokes when closed . . . no telling what was recieving them . . .

you're right other webpages were getting refreshed if the target page closed

Sorry, what you had was awful! ;) -And far more complicated BTW ^_^

Break it down.

#include <IE.au3.> ;This is just an include . . . "that means its a function a smart member has made for our use!" -they are with the install.
$oIE = _IECreate(http://www.yahoo.co.uk, 0, 1, 1, 1) ;-this is a variable ($oIE) -good for recall later, and a function (IECreate) that a member made to open a webpage.
$begin = TimerInite() ;This is just a timer. Imagine starting a stop watch here. $begin is the name of the "stop watch"

While 1 ;While 1 just keeps on running.
     Sleep(1000) ;sleep for 1 second. (because you are waiting 5 min, what's a sec or two over 5 min -plus it takes less cpu.)
     $dif = TimerDiff($begin) ;$Dif is the time since you turned on the stop watch ($begin)
     If $dif > (5 * 60 * 1000) Then ;If it has been over 5 min (min * Sec * milsec)
         $StillRunning  =  _IEAction($oIE, "refresh") ;This is a variable and another function (See smart person ^^^) to preform an IE action "Refresh" -If it works, it returns "1". You can check for "1" by the value of the Variable. You call the $variable anything you want! :-)
         If $StillRunning <> "1" then Exit ;If the $variable is not "1" -then refresh didn't work! "you can't refresh something that's closed!!! :-) Then Exit!
         $begin = TimerInite() ; if it didn't exit then it must be open. So lets start the timer again! 5 min here we come! :-)
     EndIf ;stop $StillRunning test.
WEnd  ;Start over @ while 1

Edit: Did that help any? -Your post wasn't bad, just more complex, harder to control, and older method.

Edit: Try to avoid "Send" when you can. I am guessing it was sending the keystrokes when closed . . . no telling what was recieving them . . .

Share this post


Link to post
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
Sign in to follow this  

×