firestrife23 Posted December 18, 2010 Share Posted December 18, 2010 How do i write a line of code to detect user's activity, i.e. keyboard or mouse movement? or computer's not idling? I can't seem to find information on this. Many Thanks! - J Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 18, 2010 Moderators Share Posted December 18, 2010 firestrife23.Looking at _Timer_GetIdleTime in the Help file will probably give you the answer! M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
firestrife23 Posted December 18, 2010 Author Share Posted December 18, 2010 (edited) firestrife23.Looking at _Timer_GetIdleTime in the Help file will probably give you the answer! M23Thanks for quick response, please excuse my noobish question. I'm trying to figure out a way to get it to detect the user's activity and idling. Those information will be logged with username and timestamp. I was able to get the logging function working. However, only thing is I can't figure out a way to detect user's activity. Basically I'm trying to code a small background application that'll keep track of employee's usage, similar to electricity meter. I just took a look at _Timer_GetIdleTime as you suggested, however it only seem to count how long it had been idle.- JEDIT: Grammer and spelling Edited December 18, 2010 by firestrife23 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 18, 2010 Moderators Share Posted December 18, 2010 firestrife23,I would suggest that you keep sampling the _Timer_GetIdleTime value Once it has passed a certain value (because I take it you are not interested in logging to the millisecond )you would start logging time as "idle" - if it returns to close to zero then you are "active" again.This should give youthe idea:#Include <Timers.au3> HotKeySet("{ESC}", "On_Exit") Func On_Exit() Exit EndFunc While 1 ; If idle for more than 5 secs If _Timer_GetIdleTime() > 5000 Then ; Assume Idle ConsoleWrite("Idle at " & @HOUR & ":" & @MIN & @SEC & @CRLF) ; Now idle the script until the use does something While _Timer_GetIdleTime() > 500 Sleep (10) WEnd ; Assume active ConsoleWrite("Active at " & @HOUR & ":" & @MIN & @SEC & @CRLF) EndIf Sleep(10) WEndOne request - please do not tell your employees that I helped make it! M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
firestrife23 Posted December 18, 2010 Author Share Posted December 18, 2010 firestrife23, I would suggest that you keep sampling the _Timer_GetIdleTime value Once it has passed a certain value (because I take it you are not interested in logging to the millisecond )you would start logging time as "idle" - if it returns to close to zero then you are "active" again. This should give youthe idea: #Include <Timers.au3> HotKeySet("{ESC}", "On_Exit") Func On_Exit() Exit EndFunc While 1 ; If idle for more than 5 secs If _Timer_GetIdleTime() > 5000 Then ; Assume Idle ConsoleWrite("Idle at " & @HOUR & ":" & @MIN & @SEC & @CRLF) ; Now idle the script until the use does something While _Timer_GetIdleTime() > 500 Sleep (10) WEnd ; Assume active ConsoleWrite("Active at " & @HOUR & ":" & @MIN & @SEC & @CRLF) EndIf Sleep(10) WEnd One request - please do not tell your employees that I helped make it! M23 Thank you so much, this look much cleaner and simple to follow, and Yes I'll keep it discreet as you request 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