detecting input

hi..
how will i able to detect keyboard and mouse input every moment using a program running in the background..?
prinxAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
jimbucciConnect With a Mentor Commented:
Assuming you are running on a Windows OS:
You will need to create a system keyboard and mouse hook.

From the MSDN:
WH_KEYBOARD Hook
The WH_KEYBOARD hook enables an application to monitor message traffic for WM_KEYDOWN and WM_KEYUP messages about to be returned by the GetMessage or PeekMessage function. You can use the WH_KEYBOARD hook to monitor keyboard input posted to a message queue.

For more information, see the KeyboardProc function.

WH_MOUSE Hook
The WH_MOUSE hook enables you to monitor mouse messages about to be returned by the GetMessage or PeekMessage function. You can use the WH_MOUSE hook to monitor mouse input posted to a message queue.

For more information, see the MouseProc function.

Look at SetWindowsHookEx().

There are examples in the MSDN for how to install and use hooks.
I hope this helps.
Jim

0
 
prinxAuthor Commented:
den it is possible to intercept the messages for eg..stopping particular keydown event from being handled by its app ?
0
 
prinxAuthor Commented:
den it is possible to intercept the messages for eg..stopping particular keydown event from being handled by its app ?
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
prinxAuthor Commented:
den it is possible to intercept the messages for eg..stopping particular keydown event from being handled by its app ?
0
 
prinxAuthor Commented:
den it is possible to intercept the messages for eg..stopping particular keydown event from being handled by its app ?
0
 
prinxAuthor Commented:
den it is possible to intercept the messages for eg..stopping particular keydown event from being handled by its app ?
0
 
jimbucciCommented:
From what I remember about hooks - your hook gets the message and determines what to do with.  It can throw it away thus preventing the app from getting the message, or pass it on to the next hook in the chain - which would probably be the system hook.  If it passes it on the app would get the message.
So, the answer is yes.
Jim
0
All Courses

From novice to tech pro — start learning today.