Sign in to follow this  
Followers 0
firestrife23

detect idling or user activity?

5 posts in this topic

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

Share this post


Link to post
Share on other sites



firestrife23.

Looking at _Timer_GetIdleTime in the Help file will probably give you the answer! :x

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

firestrife23.

Looking at _Timer_GetIdleTime in the Help file will probably give you the answer! :x

M23

Thanks 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.

- J

EDIT: Grammer and spelling

Edited by firestrife23

Share this post


Link to post
Share on other sites

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 :x )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! :P

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

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 :P )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! :shifty:

M23

Thank you so much, this look much cleaner and simple to follow, and Yes I'll keep it discreet as you request :x

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0