-
Hi I have an app that goes full screen after the mouse has not been moved for about 5mins..
It works but it you happen to be typing for that time then it fires up..
Is there any way to hock into the windows Idle time.. e.g. no mouse moving and no keys presed?
I dont want to make my app into a screen saver because it can not work that way.
Thanks,
-
You could use the getasynckeystate api call to detect if any of the common keys are pressed. (check every second). you don't have to check for every key. Personally, i would just check for the space bar, arrow keys, mouse buttons, and the wheel of fortune favorites: rstlne
If you check for keypresses every 100 millisec or so, you are almost gauranteed to hit a pressed key.
To try this sample, be sure to copy the relavent api delcarations into the module you put this in. Also it is better to use gettickcount. I used the timer for simplicity of example.
Code:
submain()
dim settime as long
settime = timer
do
if iskeypressed(vbkeylbutton) then settime = timer
if iskeypressed(vbkeyspace) then settime = timer
if iskeypressed(vbkeyR) then settime = timer
if iskeypressed(vbkeyE) then settime = timer
'continue for the other letters
loop until timer - settime >= 5000 '5 seconds(?)
call activatescrnsaver()
exit sub
put in a module with declarations:
Function IsKeyPressed(VBKey As Long) As Boolean
Dim KeyState As Integer
KeyState = GetAsyncKeyState(VBKey)
If KeyState And &H8000 = &H8000 Then
IsKeyPressed = True: Debug.Print VBKey
Else
IsKeyPressed = False
End If
End Function
-
By the way, if that code is too unruly, i have code for directx that will send an event to vb whenever a key is pressed. The above code is smaller. However, you could argue that the directx code is more efficient.
If you want it, post here.
It was written for directx7, but might work on a lower one (its not like i'm making 3-d rotating representations of a key you press :D)