Jump to content

Simple anti-auto-logout script


Recommended Posts

I created this script to keep from being logged out of a game called Runescape. They have an annoying "feature" that auto logs you off of the game if you are idle for more than 90 seconds. I found that moving the mouse even a little periodically is enough to abort that, so here was my solution. I went to extra lengths to keep it unobtrusive during active use and random in its timing and activity to avoid raising flags from the Game Gestapo.

; ----------------------------------------------------------------------------
; AutoIt Version: 3.1.0
; Author:        SpookMeister <myemail@nowhere.com>
; Script Function:
;   Periodically moves the mouse to avoid being auto logged out of games 
;   (screensavers too).
; ----------------------------------------------------------------------------

; Press ESC to terminate program
HotKeySet("{ESC}", "Terminate")

Global $LastPosX
Global $LastPosY
Global $CurPosX
Global $CurPosY

$pos = MouseGetPos()
$LastPosX = $pos[0]
$LastPosY = $pos[1]

; Main loop
   $sec = Random(30,45,1)
   sleep($sec * 1000)

; See if the mouse has moved since the last time checked
Func CheckMove()
   $pos = MouseGetPos()
   $CurPosX = $pos[0]
   $CurPosY = $pos[1]
   IF $CurPosX = $LastPosX AND $CurPosY = $LastPosY THEN DoSomeThing()
  ; Update vars to be able to detect changes on next iteration 
   $LastPosX = $CurPosX 
   $LastPosY = $CurPosY

Func DoSomething()
  ; Make sure you don't get a null movement if random returns 0 for both coords
      $ranX = Random(-1,1,1)
      $ranY = Random(-1,1,1)
   Until $ranX <> 0 AND $ranY <> 0
   MouseMove($CurPosX + $ranX, $CurPosY + $ranY)
   MouseMove($CurPosX , $CurPosY)

Func Terminate()

[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

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

  • Recently Browsing   0 members

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