Skrip Posted June 12, 2006 Share Posted June 12, 2006 (edited) #include <File.au3> Sleeper() Func Sleeper() _FileWriteLog("C:\AutoIt3\afk.dat", "-AFK-") $How_long = 3000; 3 seconds $pos1 = MouseGetPos() $Time = TimerInit() While 1 $dif = TimerDiff($Time) If $dif > $How_long Then; if not moved for 3 seconds then> $pos2 = MouseGetPos() If $pos1[0] = $pos2[0] Then Msgbox(0, "Away", "Away") Return EndIf EndIf Sleep(20) WEnd EndFunc It only works for that pixel, move your mouse to 1,1 then run it then quickly move it to a different pixel, then stop moving it.........doesn't work. Move it back to 1,1 then it pops up, I can't figure out how to fix it. Edited June 12, 2006 by Firestorm [left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left] Link to comment Share on other sites More sharing options...
Bundy Posted June 12, 2006 Share Posted June 12, 2006 At first look If $pos1[0] = $pos2[0] Then You shoud use '==' Link to comment Share on other sites More sharing options...
nfwu Posted June 12, 2006 Share Posted June 12, 2006 A very simple logic error: Func Sleeper() _FileWriteLog("C:\AutoIt3\afk.dat", "-AFK-") $How_long = 3000; 3 seconds $pos1 = MouseGetPos() $Time = TimerInit() While 1 $dif = TimerDiff($Time) If $dif > $How_long Then; if not moved for 3 seconds then> $pos2 = MouseGetPos() If $pos1[0] = $pos2[0] Then Msgbox(0, "Away", "Away") Return EndIf $pos1 = MouseGetPos() EndIf Sleep(20) WEnd EndFunc #) TwitterOut of date stuff:Scripts: Sudoku Solver | Webserver | 3D library (Pure AutoIt) | Wood's GadgetsUDFs: _WoodUniqueID() | _DialogEditIni() | _Console*() | _GetIPConfigData() | _URLEncode/Decode() Link to comment Share on other sites More sharing options...
Skrip Posted June 12, 2006 Author Share Posted June 12, 2006 Hmm, It doesn't work. I can't find out why! Run it then keep moving your mouse, in 3 seconds the 'away' msgbox pops up... [left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left] Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted June 12, 2006 Moderators Share Posted June 12, 2006 Makes sense to reset the timer if the coords didn't match? Otherwise after the initial TimerDiff($Time) it's always > than 3 seconds. Func Sleeper() ;_FileWriteLog("C:\AutoIt3\afk.dat", "-AFK-") $How_long = 3000; 3 seconds $pos1 = MouseGetPos() $Time = TimerInit() While 1 $dif = TimerDiff($Time) If $dif >= $How_long Then; if not moved for 3 seconds then> $pos2 = MouseGetPos() If $pos1[0] == $pos2[0] Then Msgbox(0, "Away", "Away" & @CR & $pos1[0] & @CR & $pos1[1] & @CR & @CR & $pos2[0] & @CR & $pos2[1] & @CR & 'Time Elapsed = ' & TimerDiff($Time) / 1000) Return 1 Else $Time = TimerInit() ;~ Reset Timer if not = coords (reason for the msgbox keep going off $pos1 = $pos2 = ;~ Reset to new coords EndIf EndIf Sleep(20) WEnd EndFunc Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Skrip Posted June 13, 2006 Author Share Posted June 13, 2006 Thanks works great! [left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left] 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