Hi,
When checking the computer inactivity time with this script:
set idleTime to (do shell script "ioreg -c IOHIDSystem | perl -ane 'if (/Idle/) {$idle=(pop @F)/1000000000; print $idle,\"\";last}'") as integer
will these events executed by an AppleScript be considered as activity if I checked again the inactivity time:
¢ quitting iPhoto
¢ synchronizing MobileMe (see script below)
¢ permutating to a different non-passworded user (see script below)
Thanks in advance.
Robert
…
MobileMe synchronizing script
tell application "System Events"
tell process "SystemUIServer"
repeat with mni in (get menu bar items of menu bar 1)
if (value of attribute "AXDescription" of mni as string) is "" then
perform action "AXPress" of mni
set NameList to name of menu items of menu of mni
if item 1 of item 1 of NameList begins with "Dernière synchronisation .Mac" then
perform action "AXPress" of menu item "Synchroniser" of menu of mni
exit repeat
end if
end if
end repeat
end tell
end tell
…
User permutating script
do shell script "/Applications/Scripts/ShellScripts/Permutation508A.sh"
By trial and error, I am getting closer to a solution to my problem. I still have difficulty trying to figure out which process restarts the system’s inactivity timer. Will the instruction below in a script generate activity in the system, restarting the computer’s inactivity timer to 0 ?
do shell script "/System/Library/CoreServices/Menu\\ Extras/User.menu/Contents/Resources/CGSession -switchToUserID 508"
Thanks in advance.
You can test something like that by grabbing the current date before & after.
set x to current date
delay 3
do shell script "/System/Library/CoreServices/Menu\\ Extras/User.menu/Contents/Resources/CGSession -switchToUserID 502"
delay 3
do shell script "/System/Library/CoreServices/Menu\\ Extras/User.menu/Contents/Resources/CGSession -switchToUserID 508"
set y to current date
set z to y - x
With the above script, I get 6 each time, but my userid’s have passwords, so it never actually switches users.
Hi cwtnospam,
Am I correct to say that CurrentDate will give the difference between 2 different moments, but will not give any information on the idleTime of the computer.
Yes, sorry. I meant to get the idletime in between:
delay 3
set x to do shell script "ioreg -c IOHIDSystem | awk '/HIDIdleTime/ {print int($NF/1000000000); exit}'"
do shell script "/System/Library/CoreServices/Menu\\ Extras/User.menu/Contents/Resources/CGSession -switchToUserID 502"
delay 3
do shell script "/System/Library/CoreServices/Menu\\ Extras/User.menu/Contents/Resources/CGSession -switchToUserID 508"
set y to do shell script "ioreg -c IOHIDSystem | awk '/HIDIdleTime/ {print int($NF/1000000000); exit}'"
display dialog x & " " & y
I get 3 & 6, which indicates that calling switchtouserid doesn’t affect idletime.