Jump to content

After 15min Website refresh


Recommended Posts

Hello!

I'd like to have a script, with  which it is possible that if the computer mouse don't move after 15min it will close website and open it again

Can you help me?

<{POST_SNAPBACK}>

here's one way to do it, without having to use any external UDF's just for simplicity. this basically just runs a timer. and when mouse is moved, it starts the timer over. if the timer reaches 900000 ms (15 minutes) then browser window is activated, and a ctrl + F5 is sent to force a reload. you do have to specify the title for it to work correctly....and i used the Pause key as a script exit again... i always use that for infinite loops...

$START = TimerInit()
$pos = MouseGetPos()
HotKeySet("{PAUSE}","STOPIT")
while 1
    $newpos = MouseGetPos()
    if $pos[0] <> $newpos[0] or $pos[1] <> $newpos[1] Then
        $pos = MouseGetPos()
        $START = TimerInit()
    EndIf
    if TimerDiff($START) >= 900000 Then
        WinActivate("Browsertitle")
        send("^{F5}")
    EndIf
    sleep(200)
WEnd
Func STOPIT()
    Exit
EndFunc
Link to comment
Share on other sites

Can you help me?

sure: Read at least the following sections in the help file: "While loop", "TimerInit", "Timerdiff", "MouseGetPos", "if statement", "WinClose" and "Run". This will help you to develop such a script.

Cheers

Kurt

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to comment
Share on other sites

Hi !

I had make a few changes

$START = TimerInit()
$pos = MouseGetPos()
while 1
    $newpos = MouseGetPos()
    if $pos[0] <> $newpos[0] or $pos[1] <> $newpos[1] Then
        $pos = MouseGetPos()
        $START = TimerInit()
    EndIf
    if TimerDiff($START) >= 9000 Then
        ProcessClose ( "mozilla.exe" )
    #include <Process.au3>   
    $rc = _RunDos("start iexplore -k www.ksk.ch")
    EndIf

WEnd

Now the problem is, the internet explorer does not start, but why?

Edited by Wanzler
Link to comment
Share on other sites

I had make a few changes

no, technically, you only HAD to change the title of the browser window.

ProcessClose ( "mozilla.exe" )
    #include <Process.au3>   
    $rc = _RunDos("start iexplore -k www.ksk.ch")
    EndIf

WEnd

Now the problem is, the internet explorer does not start, but why?

few things....

1) you're ending a mozilla process, but trying to start an IE process

2) why rundos instead of just run if you want to start a new browser instead of just reloading the page?

3) as i kind of touched on in #2, why kill and restart browser if all you want is a refresh? the control f5 i sent in my code does a forced full refresh, or you could just send f5, or if you really want to make unnecessary steps without hurting your efficiency as much, you could download dale's ie.au3, and then the code would be:

#include <ie.au3>
$oie = _IECreate()
_IENavigate($oie,"www.ksk.ch")

$START = TimerInit()
$pos = MouseGetPos()
HotKeySet("{PAUSE}","STOPIT")
while 1
    $newpos = MouseGetPos()
    if $pos[0] <> $newpos[0] or $pos[1] <> $newpos[1] Then
        $pos = MouseGetPos()
        $START = TimerInit()
    EndIf
    if TimerDiff($START) >= 900000 Then
        _IENavigate($oie,"www.ksk.ch")
    EndIf
    sleep(200)
WEnd
Func STOPIT()
    _IEQuit($oie)
    Exit
EndFunc

now, that will load the page when the script starts, and after 15 minutes of inactivity will reload the page in the same window. if you use the pause hotkey to terminate the script, the browser window closes first. to use this script you will need to be using the beta, and have dales ie.au3 UDF that is availible in the scripts and scraps i think, and linked to extensively (because it's just that awesome) throughout the forums. i didn't do it this way with the first code because it wasn't necessary and was trying to show you quick easy way that didn't need beta or udf's, but this way will do it the way that you want it

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