Hello dear monasterians,
I'm trying to write a script that will do a specific function when the computer shell be untouched for 15 minutes. I was wondering how to do that because after reading
Win32::Process i couldn't find there anything that tells for 'how long' the computer been idle (just the timeout when to die). I found in the following post a small code to use
Win32::API but it is unclear to me,
Checking that local Windows machine is idle, and the monasterian that posted that code wasn't in the monastery for 4 years so there's no-one to ask in person.
I'm trying to do something that would look like :
#!/usr/bin/perl -w
use strict;
# use some Win32 module for the task
# the checking if anything been pressed logically combined with perl s
+eems to me to look like
my $trials = 20; # for 10 minutes
while ($trials) {
if (("mouse moved") or ("any key pressed")) {
$trials = 20; # start the countdown all over again
} else {
$trials--; #decrease a trial
sleep(30); #wait half a minute
}
}
#now that $trials equals to 0 - therefore nothing been pressed for 10
+minutes (20 halves of a minute {for better results})
doMyFunc($var1, $var2);
sub doMyFunc {
...
}
now my question is how to properly implement the part of the code where perl should determine the "idle state" of Win32, in which the user neither presses anything nor moves the mouse ?