Cannot capture media key press

752 Views Asked by At

I am attempting to write an Auto HotKey script involving the media keys of my keyboard, but the key presses, such as Media_Play_Pause, do not seem to correspond to my media keys.

While the media keys on my keyboard (Logitech Wireless K360) work on media applications (tested on iTunes, Spotify, VLC, WMP) I cannot capture the press. Nothing shows up when I use the Auto HotKey script in from this post https://superuser.com/questions/368633/play-pause-pandora-com-with-a-media-key or when I am in the Keyboard Shortcuts settings in Google Chrome.

Thoughts?

2

There are 2 best solutions below

0
On BEST ANSWER

If you access the 'players.ini' file in SetPoint, you can actually add different programs and apps to Set Point's functionality.

Steinerd.com, http://steinerd.com/developments/hacks/media-keys/ had the most comprehensive explanation that I was able to find.

TL:DR (from https://gist.github.com/julianxhokaxhiu/f5ea4bb922e3ab1d7fec)

  1. Open C:\Program Files\Logitech\SetPointP\players.ini

  2. Add these lines to their respective sections

[Players]

GooglePlayMusic=key,chrome.exe,Chrome_WidgetWin_1,xxx,xxx,&0xB3,&0xB3,&0xB2,&0xB1,&0xB0,0,1,Google Play Music

[Players.Run]

GooglePlayMusic=path,%USERPROFILE%\AppData\Local\Google\Chrome\User Data\Default\Web Applications_crx_icppfcnhkcmnfdhfhphakoifcfokfdhg\Google Play Music.ico

[Players.Display]

GooglePlayMusic=Google Play Music

  1. Restart your PC - OR - Kill 'Logitech SetPoint Event Manager' via Task manager and reopen the Logitech Setpoint software settings from Start menu or Control Panel
3
On

That script appears to be deprecated, not the code it's self, but it's function. What immediately popped out to me was that Pandora has added Shortcut Keys to the site, no longer requiring you to tab over controls. Space will activate Play/Pause, Right Arrow is Next Song, etc. The directions from that script to find a Special Key value (SCXXX part) is still valid and you can use that assign the rest of the function keys. Below is a working example using the latest version of AutoHotkey from www.ahkscript.org

; SC122 is Media_Play_Pause 

#If WinActive("Pandora Internet Radio") And WinExist(ahk_class Chrome_WidgetWin_1)
SC122::Send, {Space}