|
-
Mar 28th, 2000, 05:44 AM
#2
Frenzied Member
You can use the GetCursorPos API to get the cursor position. Save the cursor position value into a private variable once in form load, and then in a timer and get the new value into a temporary variable. If they match, then you can increment your private timer variable (assuming the user hasn't pressed a key). If they don't match, then the user moved the mouse, so the private cursor position variable should be updated to the new temp variable, and the private timer variable should be reset to 0.
Use the GetAsyncKeyState and GetKeyboardState APIs to capture keypresses. If the user hasn't pressed a key, then increment the timer. If they have, then reset the timer to 0.
Combine these two processes so you have something like this pseudocode:
Code:
'This would be inside a Timer Event
If Not MouseMoved() And Not KeyPressed() Then
IncrementTimerVariable()
Else
SetTimerToZero()
End If
Then, you can have another function that tests the value of your Timer variable, and if it is greater than or equal to a set value, you disable your application, as in this pseudocode:
Code:
'This is also in the Timer Event
If TimerVariable >= MaxAllowedIdleTime Then
DisableApp()
End If
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|