Idle Time
Idle Time
- Subject: Idle Time
- From: Jeffrey Berman <email@hidden>
- Date: Sat, 15 May 2004 13:32:05 -0500
I have some script actions I want to occur only if the computer has been
idle for some period of time. My machine is running OS X 10.2.8 and I have
been using 'ioreg' in the syntax below to obtain an idle time. Does anyone
know if there is a simpler way to access the time during which there has
been no keyboard or mouse actions?
-Jeffrey Berman
----- Attachment follows -----
do shell script "ioreg -c IOHIDSystem | awk '/Idle/ {x = $5} END {print x}'"
return hex2Dec(text from character 2 to -2 of result) / 1.0E+9
-- seconds computer has been idle
on hex2Dec(hexNum)
set decNum to 0
set hexDigits to "123456789ABCDEF"
set Nbdigits to (length of hexNum) - 1
repeat with i from 0 to Nbdigits
set lastOne to character (Nbdigits + 1 - i) of hexNum
set decNum to decNum + (offset of lastOne in hexDigits) * (16 ^ i)
end repeat
return decNum
end hex2Dec
----- End of attachment -----
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.