How do I write a proggie that waits for some particular keystrokes and then does something? Do I have to use windows hooks? Is there any other way?
Use "RegisterHotKey" API to register hotkeys and respond to WM_HOTKEY message.
I' m not sure if it will work 'cause I'm trying to write a proggie which will work with one of those multimedia keyboards, so I want to react for keys like "Volume Up" or something...
"RegisterHotKey" works fine with those special keys.
Checkout the source I have attached. It uses some special keys on my Microsoft natural keyboard pro to change track in Winamp.
Checkout the source I have attached. It uses some special keys on my Microsoft natural keyboard pro to change track in Winamp.
Uploaded the wrong source:)
Thanx! This is exactly what I was trying to do :)
Uh... but there's another problem. How do I get virtual-key codes to use with my keyboard? I don't know them and guessing doesn't seem as a good idea... :confused:
It ain't that easy :( I managed to write a simple proggie which reads virtual-key codes (using windows hooks) and there's another problem: for some keys (there are 6 of them) I get a VK=FF. I can distinguish them by their scan codes only and RegisterHotKey can't work with scan codes, can it?
One more thing: when I catch some key, can I modify the VK code and pass it back to Windows to make it do its job as if the user pressed some other key? I mean: I install a hotkey on Esc and when sb pushes Esc I change it to Enter and pass it back to Windows?
One more thing: when I catch some key, can I modify the VK code and pass it back to Windows to make it do its job as if the user pressed some other key? I mean: I install a hotkey on Esc and when sb pushes Esc I change it to Enter and pass it back to Windows?
No, even with hooks you can't modify the key code. You can prevent it from being processed though, with hooks. But then you will need to find a way to send the character yourself.
Thomas
When the original software for my keyboard is running, it filters keystrokes before my proggie! How is this possible if it's not a driver and I'm using hooks?
About hooks: my keyboard hook must reside in a dll, therefore I need to have two files - dll and exe, and the latter does nothing more than loading the first... Is there any way to put all this into one executable?
@ante: how did you get all those control IDs you send to Winamp? I ripped all Winamp resources with Restorator and found some accelareator IDs which also work but how did you get yours?
I found them on Winamp?s site: http://www.winamp.com/nsdn/winamp2x/dev/sdk/api.jhtml;$sessionid$J1WJJOZ31MKCJTN245JBC0A
My keyboard is a b#%ch to me! There are some keys that can only be distinguished by scan codes (VK=255), so I tried to make all keys working (those with VKs, too) using windows hooks. But, e.g. my "Eject" key has a VK=VK_LAUNCH_APP2 and everytime I press it, Windows launches Calculator as well. I don't know how to stop Windows from doing it. The only solution I can think of, is to use hooks for keys with VK=255 and RegisterHotKey API for other keys...
Is there a way for a keyboard proc to remove WM_KEYDOWN message from message que? Perhaps with GetMessage but what window handle should I use?
Is there a way for a keyboard proc to remove WM_KEYDOWN message from message que? Perhaps with GetMessage but what window handle should I use?