squeak ha scritto:
Hi there,
I'm new to VB2005 so its probably a very simple answer too! But i just
can't think how to do it...
Basically i need to detect mouse (and preferably keyboard) movement and
kepresses when my application is just minimized and not the active
forground app.
I only need to triger an event which is going to tell my app if the
user has moved the mouse recently and decide if the workstation is now
idle, nothing more - so any ideas?
cheers in advance!
- - rob - -
hi rob, you got to attach a hook routine to the keyboard or mouse
messages:
create a public class with two public sub, startListen and stopListen,
and a public event, KeyPressed returning key's been pressed.
here's the keyboard procedure:
Public Function MyLLKbdProc(ByVal nCode As Integer, ByVal wParam As
IntPtr, ByVal lParam As IntPtr) As IntPtr
RaiseEvent KeyPressed(Marshal.ReadInt32(lParam))
Return CallNextHookEx(KeyBoardHook, nCode, wParam, lParam)
End Function
and this is the calling routine;
Public Sub KeyBoardListen()
Dim hp1 As HookProc = AddressOf MyLLKbdProc
KeyBoardHook = SetWindowsHookEx(WH_KEYBOARD_LL,
hp1, Marshal.GetHINSTANCE(GetType(Hook).Module), 0)
GC.KeepAlive(hp1)
End Sub
hope this help, fabio