lilphil
March 5th, 2003, 10:53 PM
This topic has kindof two angles to it, so I'll cover both.
1) There's the generating a 'softkey' event so that, for instance, when you press next on the remote it sends a WM_APPCOMMAND next event to your specified program, or foreground process.
2) Then theres the receiving the 'softkey' event, and doing something else with it. Eg, press the stop button to close your favourite program.
The first case is fairly easy to do (Thanks to Kristans information)
Here are some of the lParams for your information:
Mute - 524288
Volume down - 589824
Volume up - 655360
Play / Pause - 917504
Stop - 851968
Previous track - 786432
Next track - 720896
For example, to send a next event to winamp, use the SendMessage plugin with the following information
Message Number: 793
wParam: 0
iParam: 720896
and target Class name "Winamp v1.x"
(Hint, if you match invisible tasks this will work when winamp is in the systray too)
Don't forget, this is generating a Next softkey event, and unless there is a specific reason to do so you're probably better just using winamps SDK to send a Winamp specific event. Specific reason may be that you want to control anything thats in the foreground which the softkeys do quite well. In my case, the softkeys get passed on from winamp to Hey Mr DJ if its loaded.
In the second case, it's very easy to grab a softkey event as you would a normal key, but the problem arises when you want to block that event from whatever application is in the foreground.
Girder can't do this because windows wont let it, but you can play some sneaky tricks, by editing the registry you can change the key from generating the 'softkey next' event to generating another key press. Eg F11 or something, which has obvious benefits.
You may have the problem I had, that you would like a next event sent to winamp when next is pressed, which works fine when winamp *doesn't* have window focus, but picks up on both the girder event and the window event. When it does, you can tell girder to 'Stop Processing' when winamp 'IsForeground'.
How handy :)
So, a bit more information on editing that registry. The area of interest is
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Contro l\Keyboard Layout
where you need to add a REG_BINARY called 'Scancode Map'
This is where things get interesting... you need to work out what data to put in it.
As posted by Ron, the following links are very useful
http://www.kiss.taihaku.sendai.jp/~fuji/product/scancode.html
http://support.microsoft.com/default.aspx?scid=KB;en-us;q181348
Its going to look something like this (Using mine as an example)
0000 00 00 00 00 00 00 00 00
0008 05 00 00 00 01 E0 32 E0
0010 02 E0 6C E0 03 E0 65 E0
0018 04 E0 66 E0 00 00 00 00
Now this is where i'm a little fuzzy, cos it was a long time ago now that I did it. The Microsoft website says the first value should be the "Size of the scancode map including header, in bytes" but it the Japanese site doesn't mention it, and I havn't included it. Who knows, but suffice to say it works for me without. The bunch of zeros on the first line are the two headers so we can leave them as they are.
Then the next value (05 00 00 00) is the number of entries including the null terminator. As you can see, I have four entries (Home, Mail, Search and Go keys on the Logitech Cordless Desktop Pro keyboard)
This page is quite useful to find out your scancodes:
http://www.win.tue.nl/~aeb/linux/kbd/scancodes.html
I wanted to pick some codes that (afaict) are unused, so that other programs in windows wont be affected. So I figured I would use E001, E002, E003, and E004 (don't take my word on these, they might be used by your keyboard)
So the first entry is 01 E0 32 E0 which maps the Home button on my keyboard (E032) to E001. Then after all the entries comes the 00 00 00 00 null terminator.
Sorted
1) There's the generating a 'softkey' event so that, for instance, when you press next on the remote it sends a WM_APPCOMMAND next event to your specified program, or foreground process.
2) Then theres the receiving the 'softkey' event, and doing something else with it. Eg, press the stop button to close your favourite program.
The first case is fairly easy to do (Thanks to Kristans information)
Here are some of the lParams for your information:
Mute - 524288
Volume down - 589824
Volume up - 655360
Play / Pause - 917504
Stop - 851968
Previous track - 786432
Next track - 720896
For example, to send a next event to winamp, use the SendMessage plugin with the following information
Message Number: 793
wParam: 0
iParam: 720896
and target Class name "Winamp v1.x"
(Hint, if you match invisible tasks this will work when winamp is in the systray too)
Don't forget, this is generating a Next softkey event, and unless there is a specific reason to do so you're probably better just using winamps SDK to send a Winamp specific event. Specific reason may be that you want to control anything thats in the foreground which the softkeys do quite well. In my case, the softkeys get passed on from winamp to Hey Mr DJ if its loaded.
In the second case, it's very easy to grab a softkey event as you would a normal key, but the problem arises when you want to block that event from whatever application is in the foreground.
Girder can't do this because windows wont let it, but you can play some sneaky tricks, by editing the registry you can change the key from generating the 'softkey next' event to generating another key press. Eg F11 or something, which has obvious benefits.
You may have the problem I had, that you would like a next event sent to winamp when next is pressed, which works fine when winamp *doesn't* have window focus, but picks up on both the girder event and the window event. When it does, you can tell girder to 'Stop Processing' when winamp 'IsForeground'.
How handy :)
So, a bit more information on editing that registry. The area of interest is
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Contro l\Keyboard Layout
where you need to add a REG_BINARY called 'Scancode Map'
This is where things get interesting... you need to work out what data to put in it.
As posted by Ron, the following links are very useful
http://www.kiss.taihaku.sendai.jp/~fuji/product/scancode.html
http://support.microsoft.com/default.aspx?scid=KB;en-us;q181348
Its going to look something like this (Using mine as an example)
0000 00 00 00 00 00 00 00 00
0008 05 00 00 00 01 E0 32 E0
0010 02 E0 6C E0 03 E0 65 E0
0018 04 E0 66 E0 00 00 00 00
Now this is where i'm a little fuzzy, cos it was a long time ago now that I did it. The Microsoft website says the first value should be the "Size of the scancode map including header, in bytes" but it the Japanese site doesn't mention it, and I havn't included it. Who knows, but suffice to say it works for me without. The bunch of zeros on the first line are the two headers so we can leave them as they are.
Then the next value (05 00 00 00) is the number of entries including the null terminator. As you can see, I have four entries (Home, Mail, Search and Go keys on the Logitech Cordless Desktop Pro keyboard)
This page is quite useful to find out your scancodes:
http://www.win.tue.nl/~aeb/linux/kbd/scancodes.html
I wanted to pick some codes that (afaict) are unused, so that other programs in windows wont be affected. So I figured I would use E001, E002, E003, and E004 (don't take my word on these, they might be used by your keyboard)
So the first entry is 01 E0 32 E0 which maps the Home button on my keyboard (E032) to E001. Then after all the entries comes the 00 00 00 00 null terminator.
Sorted