Hi! I'm the new kidd in the block.
I want to write a program that could use idle time of my computer.
I got the general idea about it but no clue about how to start.
The functionality is similar to screen savers applications. I need a program that continously monitors keyboard activity and if there is no activity in an specified time period the program starts a routine of backing up files.
My first obstacle is: How to monitor keyboard or mouse activity while running another application.
My second obstacle is: Once my program has detected n-minutes without keyboard or mouse activity I would like to confirm that no body is at the keyboard issuing a confirmation message prior to start backing up the files. If there is no answer in x-seconds the program should start the backing up routine.
I think I'll find more obstacles, but one step a time (well two).
Thanks for your answer. I did a search on getasynckeystatus and found the following snippet from Jacob Roman
VB Code:
Option Explicit
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Public Key As Integer
Private Sub Form_Unload(Cancel As Integer)
Unload Me
End Sub
Private Sub Timer1_Timer()
Key = GetAsyncKeyState(46)
If Key = -32767 Then
MsgBox "You Pressed Delete", vbExclamation
End If
End Sub
I tried it and works fine but only for delete key pressing. I need to detect any key pressing. I want to trigger a routine once x-seconds have elapsed since last key input ..
I would use a global keyboard hook (in VB you need a journal hook for that) and poll the time between keyboard activity, resetting the timer whenever you receive a hook event.