leuce Posted August 24, 2012 Share Posted August 24, 2012 (edited) G'day everyone I created a script that takes a fullscreen screenshot once a minute, so that I can check at the end of the day what my kids did on the computer (I don't need any more information than once a minute). However, if they're watching a movie, or if they had gotten up to play outside for a while, the script takes unnecessary screenshots. I thought a reasonably simple way to detect the presence of a human is to ask whether the mouse had moved. Original script: #include <date.au3> #include <ScreenCapture.au3> SnapDeSnap() ; first snap when script starts While 1 Sleep ("60000") SnapDeSnap () WEnd Func SnapDeSnap() $nowdatetime = StringReplace (StringReplace (_NowCalc(), "/", "-"), ":", "-") _ScreenCapture_SetJPGQuality(75) _ScreenCapture_Capture($nowdatetime & " " & @UserName & ".jpg", 0, 0, -1, -1, True) EndFunc However, after updating my script with what I had thought would work, it still takes a screenshot every minute, even if I'm not at the computer for several minutes (and no, it aint the cat). Can anyone tell me what is wrong with the updated script? Updated script: #include <date.au3> #include <ScreenCapture.au3> SnapDeSnap() ; first snap when script starts While 1 $mousewhereone = MouseGetPos () Sleep ("60000") $mousewheretwo = MouseGetPos () If $mousewhereone <> $mousewheretwo Then SnapDeSnap () EndIf WEnd Func SnapDeSnap() $nowdatetime = StringReplace (StringReplace (_NowCalc(), "/", "-"), ":", "-") _ScreenCapture_SetJPGQuality(75) _ScreenCapture_Capture($nowdatetime & " " & @UserName & ".jpg", 0, 0, -1, -1, True) EndFunc Added: By the way, in case there is confusion: I don't want a screenshot taken as soon as the mouse moves. I still want one screenshot every minute, but I don't want a screenshot if the mouse didn't move in the past minute. Thanks in advance Samuel Edited August 24, 2012 by leuce Link to comment Share on other sites More sharing options...
Bert Posted August 24, 2012 Share Posted August 24, 2012 There is a mouse udf that will work well with what you have in mind. The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
stormbreaker Posted August 24, 2012 Share Posted August 24, 2012 i don't think you could two 'arrays' like that. Compare their elements. ---------------------------------------- :bye: Hey there, was I helpful? ---------------------------------------- My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1 Link to comment Share on other sites More sharing options...
leuce Posted August 24, 2012 Author Share Posted August 24, 2012 i don't think you could two 'arrays' like that. Compare their elements. Yes, I had hoped that I could keep the code short, but I had a nagging feeling about exactly what you say here. And it worked (thanks!): While 1 $mousewhereone = MouseGetPos () $mousewhereonecalc = $mousewhereone[0] & " " & $mousewhereone[1] Sleep ("60000") $mousewheretwo = MouseGetPos () $mousewheretwocalc = $mousewheretwo[0] & " " & $mousewheretwo[1] If $mousewhereonecalc <> $mousewheretwocalc Then SnapDeSnap () EndIf WEnd Samuel Link to comment Share on other sites More sharing options...
Mordred Posted August 24, 2012 Share Posted August 24, 2012 I realize you've already got it working, but you could probably simplify the code a lot by using _Timer_GetIdleTime(). That'll check for keyboard and mouse movements. Something like this should work:While 1 If _Timer_GetIdleTime() < 60000 Then SnapDeSnap() EndIf Sleep (60000) WEnd Serg2000mr 1 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