ohayden
asked on
Keyboard Callback
Does anyone have an example for the SetWindowsHookEx for the keyboard callback? I keep trying but the API returns 0 each time. I need to be able to trap any keys pressed in Windows.... Thanks.
Maybe you mistake some parameters.
Anyway, what I wanted to tell you is that monitoring all keystrokes is a bit complex with VB. Windows needs a global module for the callback and VB cannot supply such. The only solution is using a DLL, as Dlls are global modules.
You'll have to write a Dll callback function to receive the keystroke messages
Anyway, what I wanted to tell you is that monitoring all keystrokes is a bit complex with VB. Windows needs a global module for the callback and VB cannot supply such. The only solution is using a DLL, as Dlls are global modules.
You'll have to write a Dll callback function to receive the keystroke messages
There's a PAQ that explains some of the basics, with code examples.
https://www.experts-exchange.com/topics/comp/lang/visualbasic/Q.10100692
Before you go visit it and spend the 30 points, I'll warn you that you have to check for specific keys. Unlike VB events, where a key is pressed and you are sent info on what key was pressed, it's more like you say "Was <x> pressed?" as the system returns yes or no.
I rewrote the code in the PAQ into a cleaner version. Let me know if you'd like to see it.
https://www.experts-exchange.com/topics/comp/lang/visualbasic/Q.10100692
Before you go visit it and spend the 30 points, I'll warn you that you have to check for specific keys. Unlike VB events, where a key is pressed and you are sent info on what key was pressed, it's more like you say "Was <x> pressed?" as the system returns yes or no.
I rewrote the code in the PAQ into a cleaner version. Let me know if you'd like to see it.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Anyway, what I wanted to tell you is that monitoring all keystrokes is a bit complex with VB. Windows needs a global module for the callback and VB cannot supply such. The only solution is using a DLL, as Dlls are global modules.
You'll have to write a Dll callback function to receive the keystroke messages