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?
Posted on 2002-04-13 12:14:49 by marcinbu
Use "RegisterHotKey" API to register hotkeys and respond to WM_HOTKEY message.
Posted on 2002-04-13 13:47:16 by ante
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...
Posted on 2002-04-13 13:59:24 by marcinbu
"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.
Posted on 2002-04-13 14:08:58 by ante
Uploaded the wrong source:)
Posted on 2002-04-13 14:19:04 by ante
Thanx! This is exactly what I was trying to do :)
Posted on 2002-04-13 14:25:44 by marcinbu
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:
Posted on 2002-04-13 14:27:59 by marcinbu
Posted on 2002-04-13 14:59:24 by ante
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?
Posted on 2002-04-13 15:25:56 by marcinbu
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?
Posted on 2002-04-13 15:29:39 by marcinbu

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
Posted on 2002-04-13 16:55:23 by 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?
Posted on 2002-04-14 01:42:53 by marcinbu
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?
Posted on 2002-04-14 03:14:37 by marcinbu
@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?
Posted on 2002-04-14 05:35:34 by marcinbu
I found them on Winamp?s site: http://www.winamp.com/nsdn/winamp2x/dev/sdk/api.jhtml;$sessionid$J1WJJOZ31MKCJTN245JBC0A
Posted on 2002-04-14 05:47:12 by ante
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?
Posted on 2002-04-14 07:03:57 by marcinbu