Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

Keyboard Media Keys (for USB HID devices!)

  • Please log in to reply
43 replies to this topic
  • Members
  • 1237 posts
  • Last active: Oct 20 2010 11:41 AM
  • Joined: 24 Aug 2005
This set of 2 scripts and Micha's DLL file (thanks again Micha! couldn't have done it otherwise) allow you to replace the default actions of those media keys on some keyboards (like Play, Pause, Volume, etc) by defining your own actions.

This could probably also be used for other USB devices with very few changes.

I've included an instructions text file and examples/info at the top of each script file. Please take a look at them or else you probably won't get very far :)

As an example of what it can do: I've currently remapped the volume wheel on my keyboard to adjust the master volume and display a simple On Screen Display (OSD) of the action and the volume level.

Download link (zip file):
https://ahknet.autoh... ... 20Keys.zip

Micha's original script thread:

It would be helpful to others if anyone using the script could report back their keyboard make/model and if they had to change the EditUsage and EditUsagePage values from the default (all described in the zip file).

p.s. Micha, I hope you don't mind me including your DLL file in the zip file?

  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
Nice post. This will be a great resource to those who want to customize their keyboard in ways the manufacturer doesn't support.

  • Guests
  • Last active:
  • Joined: --
Hi evl,
great job!

Feel free to use the dll and script in any way you desire!

Nice to see my little work be useful.

I have to mention that there could be a problem (somewhere).
I use a remote control. When I record the same key a lot of times the rawdata changes somehow.
When recording the key it shows the value "53570000". After a few times using it, the value changes to 53570053.
I guess there's something wrong with the conversion-routine or my dll. If I find something, I will post it.


  • Members
  • 1237 posts
  • Last active: Oct 20 2010 11:41 AM
  • Joined: 24 Aug 2005
Thanks for all the work and making the dll available to use :D

I haven't really seen any issues yet, but I've not been using it long enough to notice perhaps.

  • Guests
  • Last active:
  • Joined: --
Wow! This is really awesome!
I tried it with my Logitech Cordless Keyboard (I wonder how it is named...) and it was super easy to set up and it detects every single of my 30+ Media Keys apart from the second enter key I got.
I'm using this now as a sleek replacement for the clunky Logitech driver.
I just wonder why noone answered in this thread since over a year? Is there another, more supported version out?

Thanks a lot!

  • Members
  • 9 posts
  • Last active: Apr 24 2008 01:17 AM
  • Joined: 15 Oct 2007
hi, i use and i liked very much

I just want put more than one line of code
but your program just accept one line
It is possible to put more than one code in the same line?

like change this

IfWinNotActive, ahk_class BSPlayer
WinActivate, ahk_class BSPlayer
IfWinActive, ahk_class BSPlayer
Send, {SPACE}

for something in one line only

Because if i change the in the file "Keyboard Media Keys Actions" and put several lines ( and work fine)
When i try to run "Keyboard Media Keys - detect keys" and add up a key
I have to go back to "Keyboard Media Keys Actions" and change again

tks very much and congratz for the excellent script

  • Members
  • 1237 posts
  • Last active: Oct 20 2010 11:41 AM
  • Joined: 24 Aug 2005
I made it only use one line of code to keep things simple. You can change it manually as you did. One solution is to have the key (the single line of code) run another script which contains the longer code you want to run.

  • Members
  • 59 posts
  • Last active: Jan 30 2014 04:41 PM
  • Joined: 25 Nov 2004
evl, thanks for the scripts. It looks like it will be useful. I have a Logitech Cordless Wave Desktop and haven't been able to map most of the keys using the conventional methods but they all seem to be detectable using this method.

One interesting key is called "Fn" which is used to activate special functions on the F1-F12 and Print Screen and Pause keys. I actually expected that this button wouldn't send any data itself, but it does. Your script detects the Fn key as soon as it is pressed. I'm wondering if there's a different code sent when the Fn key is pressed in combination with one of its target buttons or if it just sends the one code and the combination is interpreted by the Logitech driver?

Also, the Fn key is between the right Alt and Ctrl. I'd much rather it be the RWin key which I used extensively on my last keyboard as a modifier for other hotkeys. In your script, the action defined for the Fn key is executed as soon as the Fn key is pressed. Is there any way I could remap the Fn to Rwin? This would require, I think, detecting both the key down and key up events so that Rwin could be virtually pushed down then virtually released at the appropriate times.


  • Guests
  • Last active:
  • Joined: --
Hi guys, thanks a lot both for AutoHotKey and for Keyboard Media Keys library.

If was trying to force my upper buttons of split Microsoft natural keyboard to do the activating of window based on its title.

There were two problems:
1) even if I uninstalled keyboard drivers, it was starting homepage when I hit Home special button
2) keys labeled 1 to 5 were detected with same key code in Keyboard media keys(0000004800000049)

So finally I achieved what I wanted by using original Microsoft drivers and assigning AHK scripts to the keys - read "Create shortcut to activate window by title" at http://jetensky.net/... ... -by-title/

  • Members
  • 225 posts
  • Last active: Oct 03 2014 05:31 PM
  • Joined: 20 Jul 2006
Goldship Arch Slim Keyboard Office: Fn cannot be remapped, not a real key

Multimedia Keys Map:

Frits Jan
  • Guests
  • Last active:
  • Joined: --
I used this script on my mac wireless bluetooth keyboard which I use on my pc. It works great for the eject and fn button.

However I wonder if it is also possible to remap the buttons instead to run a function. For example I would like my eject button to be delete.


  • Guests
  • Last active:
  • Joined: --
ok sorry this is easy of course:

4854: ; eject -> delete
send {delete}

  • Members
  • 6 posts
  • Last active: Oct 25 2010 02:29 PM
  • Joined: 16 Jun 2008
Thank you for these scripts. I have a dell multimedia keyboard that has worked on every computer for years, except for this HP laptop that I use at work. So I used these scripts to program the volume and the media keys.

I'm wondering, I've seen some scripts that have a Bar Graph type of display for the Volume, but no matter how I tried to add them to Keyboard Media Keys Actions.ahk I kept on getting errors.

Any thoughts on how this can be achieved?

Best Regards

  • Moderators
  • 9162 posts
  • Last active: Sep 12 2014 10:36 PM
  • Joined: 30 Aug 2005
show how you are adding the code.

If you want, start a new topic in Ask for help, (with a link to this topic) and more people will see your question.

  • Members
  • 1 posts
  • Last active: Aug 21 2008 07:09 PM
  • Joined: 21 Aug 2008

I have been trying to use the tips in this thread to get the Eject button on my new compact keyboard (menat for a MAC, but I want to use it with my Shuttle PC) to do something useful. "Copy" would be useful, i.e. "send {LControl}{c}.

I cannot get it to work, though. I have used the "Keyboard Media Keys - detect keys" script, and it detects the Eject key with key code 53550048000000 (seems a bit long, can that be right?). I ran the "Keyboard Media Keys" script and it created "Keyboard Media Keys Actions", but when I run that, the Eject key is still ignored.

What could I be doing wrong, or failing to do right?