sulee154151 Posted January 16, 2016 Posted January 16, 2016 (edited) I have an autoit running as a windows service (as the SYSTEM user), and would like to detect whether the user is idle (no keyboard or mouse input). I found in a normal script I can use " _Timer_GetIdleTime". However, in my service / system user process the command does not work. Has anyone figured out a way to determine user activity/inactivity from a different process, not running as the user? _____ cong ty thi cong son epoxy, dich vu son epoxy uy tin, dich vu tim nguoi giup viec, cong ty toyota ly thuong kiet uy tin Edited January 20, 2016 by sulee154151
jguinch Posted January 16, 2016 Posted January 16, 2016 _WinAPI_GetIdleTime ? Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF
orbs Posted January 17, 2016 Posted January 17, 2016 (edited) sulee154151, welcome to the AutoIt forum! background questions: what does your script do, or intends to do? in that context, have you considered the possibility of multiple users sessions? i'm asking this because you may just find it easier to run your script in the user session, instead of the system. this will make getting idle time much easier, and may be the logical thing to do since your script obviously depends on that for its operation. if you must run as system, then you can create a user agent to report the idle time, or create a process as the user (this involves detecting multiple users). another option is described in the MSDN page for the GetLastInputInfo function, here. see the comment labeled Alternative to get system-wide user input. quote: Spoiler Alternative to get system-wide user input As stated above GetLastInputInfo does not retrieve input information across user sessions. Also if you try to call it for a service, it will succeed but will always result in returning the same tick count. That is because services are running in their own non-interactive desktop that will never receive user input. The only way to use GetLastInputInfo from a local service is to start a user-mode process in each logon user session (check CreateProcessAsUser) and call it from there. After that user-mode process needs to use IPC (such as a named-pipe, or a named global event if all you need to signal is "activity happened") to send data back to the service. There's one simpler way to retrieve system-wide activity on Windows Vista and later OS though. You'll get a "very clunky" output, but it will work system-wide. Call CallNtPowerInformation with SystemPowerInformation and examine the TimeRemaining member of the SYSTEM_POWER_INFORMATION struct. This value will be updated every "now-and-then" if there's no system-wide user activity. The question that I struggled with, is "how often is 'now-and-then'?" The answer doesn't seem to be as straightforward as it seems. It depends on the OS. For Vista it is done every 10 seconds or so, for Windows 7 - every 15 sec, and for Windows 8 - every 30 seconds. For Windows XP though, it is updated ONLY if the "Put computer to sleep" setting in the Power Options in Control Panel is set to something other than "Never". So I would not use it on XP. Edited January 17, 2016 by orbs Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff
Guest xmlkz10908 Posted June 2, 2016 Posted June 2, 2016 (edited) On 17/1/2016 at 3:30 AM, sulee154151 said: I have an autoit running as a windows service (as the SYSTEM user), and would like to detect whether the user is idle (no keyboard or mouse input). I found in a normal script I can use " _Timer_GetIdleTime". However, in my service / system user process the command does not work. Has anyone figured out a way to determine user activity/inactivity from a different process, not running as the user? _____ ib for me, I can help you giup viec nha | giup viec nha theo gio | tim nguoi giup viec Edited June 6, 2016 by xmlkz10908
Guest xmlkz10908 Posted June 2, 2016 Posted June 2, 2016 (edited) On 17/1/2016 at 3:30 AM, sulee154151 said: I have an autoit running as a windows service (as the SYSTEM user), and would like to detect whether the user is idle (no keyboard or mouse input). I found in a normal script I can use " _Timer_GetIdleTime". However, in my service / system user process the command does not work. Has anyone figured out a way to determine user activity/inactivity from a different process, not running as the user? _____ ib for me, I can help you giup viec nha | giup viec nha theo gio | tim nguoi giup viec Edited June 6, 2016 by xmlkz10908
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