Jump to content

auto refresh browser


ipodfrik
 Share

Recommended Posts

I am totally new to autoit, so please bare with me.

I want to auto refresh active firefox browser every few milliseconds (not seconds).

It would be in a loop, can be a set of loops or indefinitely.

Also, since it will be refreshed at fast rates, the script should not wait until page fully loads and ignore all browser errors.

How can I do that?

Thanks

Edited by ipodfrik
Link to comment
Share on other sites

Here are a couple things you need to look into:

If...Else..EndIf statements: http://www.autoitscript.com/autoit3/docs/keywords/IfElseEndIf.htm

Use these to detect the second item, WinActive. http://www.autoitscript.com/autoit3/docs/functions/WinActive.htm

Do an If WinActive("Name Of FireFox Window") and then send a Refresh command.

Then check into loops: http://www.autoitscript.com/autoit3/docs/keywords/While.htm

AutoIt reads Sleep functions in milliseconds, so thats no problem. Sleep(1000) = 1 second, so Sleep(100) would be 100 milliseconds :D

If you need any further help feel free to ask :oops:

And welcome to the forums!

MCR.jpg?t=1286371579

Most recent sig. I made

Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic

Link to comment
Share on other sites

Thank you,

I'm actually new to scripting,

And this is probably the easiest script to make, so I feel really dumb.

So, first I run Firefox, the load the website

While
Run("C:Program FilesMozilla Firefoxfirefox.exe")
$oIE = _IECreate ("www.website.com", 0)
Sleep(1000)
WEnd

Is this correct to reload a page with firefox in a loop?

Link to comment
Share on other sites

Here's a little jump starter:

Use this function to grab the FireFox's title to do a WinActive command.

$title = WinGetTitle("NFL", "")
MsgBox(0, "Full title read was:", $title)

I have this window open, set the "NFL" to whatever your window starts with.

http://espn.go.com/nfl/

After you have that then here's a code that might not be 100% what you want but should get you started.

HotKeySet("!{x}", "_Exit") ; Sets a shortcut to kill the script quickly. ALT+X
Opt("WinTitleMatchMode", 3) ; This is to tell the script to only refresh the EXACT window, incase there are similar windows. Such as: Window 1, Window 2.
While 1 ; This begins a While LOOP
Sleep(5000) ; Tell the script to pause for 5 seconds
  $title = WinGetTitle("Google - Mozilla Firefox", "") ; Grabs the exactly title and saves it to a variable to do an If statement against.
If WinExists($title) Then ; Check to see if the desired window is running.
  WinActivate($title) ; If it is running, first activate the window.
  WinWaitActive($title) ; This tells the script to not send the refresh key (F5) until the window has appeared.
  Send("{F5}") ; This sends the F5 key to refresh the window.
Else ; This is an else statement to tell the script to do a different operation if the window is not running.
  Sleep(10) ; Just a filler item to wait until the desired window is running.
EndIf ; End the If statement to continue the script.
WEnd ; Close the While LOOP
Func _Exit() ; This is the function that is linked to the kill switch, ALT+X. It tells the script to perform the following actions.
Exit ; In this case it is to close the entire program.
EndFunc ; Close the function up.

Let me know if you don't understand anything :D

Edited by Damein

MCR.jpg?t=1286371579

Most recent sig. I made

Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic

Link to comment
Share on other sites

The code you posted will open a FireFox window every second, and unless you have a ton of CPU thats not good :D

As for the $oIE, do you have a GUI you are using? From the Run command, I assume not.

Also, are you wanting to re-open the FireFox window each time, or is a simple refresh okay?

Edited by Damein

MCR.jpg?t=1286371579

Most recent sig. I made

Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic

Link to comment
Share on other sites

Alright, no problem.

Also, if you didn't grab the script I added comments to, you probably should.

I think I added enough detail to fully explain what the script is doing, in case you need to use parts of it in future scripts :D

Enjoy, and let us know if there's anything else you need!

Edited by Damein

MCR.jpg?t=1286371579

Most recent sig. I made

Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic

Link to comment
Share on other sites

Hi!,

I kind of got interested in this but I really didn't test this code out because I'm not really sure how to go further in doing this.

And please correct my mistake here I was not really sure while writing this code:

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 347, 113, 192, 124)
$Button1 = GUICtrlCreateButton("START Refresh Browser", 24, 72, 131, 25)
$Label1 = GUICtrlCreateLabel("Click START to refresh browser every 5 seconds", 32, 16, 234, 17)
$Button2 = GUICtrlCreateButton("Stop Refresh Browser", 176, 72, 115, 25)
$Label2 = GUICtrlCreateLabel("Click Stop to close window and stop refreshing the browser", 32, 40, 282, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
  Case $Button1
   Do
   $oIE = _IECreate ("[url="http://www.autoitscript.com"]www.autoitscript.com[/url]")
   Sleep 1000
   ContinueLoop
   Send("!F5") ;F5 key pressed to refresh browser
   Sleep 5000 ;After 5 seconds it refreshes browser again
   Until
  case $Button2
   ExitLoop
   Sleep 1000
   Exit
EndSwitch
WEnd

Thank You.

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