Can you re-assign multimedia keys?

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
omar
Posts: 545
Joined: 22 Oct 2015, 17:56

Can you re-assign multimedia keys?

01 May 2024, 08:24

Can I assign multimedia keys to run AHK code?
Seems simple and straight forward?
Would I use AHK Spy to figure out what the button pressed?
Some guidance here would be great

Sometime ago I had the great idea of buying a USB keypad with buttons and assigning them the AHK scripts.
Alas... I found out this is NOT straight forward at all. It's a mission to be able to identify specific key strokes and involves either using bespoke code that comes with the USB device and/or using other Windows drivers and/or using 100's of lines of AHK code written by others...
Have I got that wrong?
Or has it changed with V2 of AHK?

EDIT I did some research and there seems to be loads of sellers of these keypads now.
See pic below for example:

Image

Some (not all) come with software allowing you to map keys.

Thanks.
User avatar
boiler
Posts: 17162
Joined: 21 Dec 2014, 02:44

Re: Can you re-assign multimedia keys?

01 May 2024, 09:23

omar wrote: Can I assign multimedia keys to run AHK code?
Seems simple and straight forward?
Generally, yes, it's very straightforward.

omar wrote: Would I use AHK Spy to figure out what the button pressed?
No, you would check the KeyHistory of any simple AHK script to see the key presses that it recognized since the script started.

omar wrote: Alas... I found out this is NOT straight forward at all. It's a mission to be able to identify specific key strokes and involves either using bespoke code that comes with the USB device and/or using other Windows drivers and/or using 100's of lines of AHK code written by others...
Have I got that wrong?
It would only take one line of code per key to run an AHK script at the press of a key, as long as the keypresses are recognizable, which they should be and would be verified by the KeyHistory. If those keypresses are not distinguishable from other keys on the main keyboard and you want them to be, then yes, that's when you'd need to use something like AutoHotInterception. I don't see why the number of lines of code that evilC has already written is a drawback. It's not like you have to write them again.

omar wrote: Some (not all) come with software allowing you to map keys.
For such devices, it's easy to have it send a key combination that would make it unique relative to anything you might press on your main keyboard, and then you would have your AHK script define those hotkeys to run the AHK script of choice when that key combination is pressed without having to use something like AutoHotInterception. Your AHK script becomes trivially easy.
omar
Posts: 545
Joined: 22 Oct 2015, 17:56

Re: Can you re-assign multimedia keys?

04 May 2024, 02:00

Amazing reply
That's really helpful 👍

One thing I'm wary of is that these units come with their own bespoke software freshly made in China 🙃
If I can use AHK... then I'll opt for that instead
User avatar
boiler
Posts: 17162
Joined: 21 Dec 2014, 02:44

Re: Can you re-assign multimedia keys?

04 May 2024, 02:26

Well, as I suggested, it may be to your advantage to use their software to have the keys send a key combination you wouldn’t press on your own so then you can be confident that your AHK script is receiving key presses from that keyboard. I do that with foot pedals so they send something like Shift+Ctrl+F7, which I would never press myself, and my script sets a +^F7:: hotkey. However, I did waste money on a couple cheap Chinese foot pedals that had a short life before ending up with a set of much more robust and reliable pedals from a US company. It was well worth the price.

Return to “Ask for Help (v2)”

Who is online

Users browsing this forum: BPet, kiwichick, niCode, ntepa and 24 guests