Media keys not working

@TheMooDude said:
Nothing too complicated or anything. Hope it’s useful.

~Media_Next::
ControlSend,,{Media_Next},Plex Media Player
return

~Media_Prev::
ControlSend,,{Media_Prev},Plex Media Player
return

~Media_Stop::
ControlSend,,{Media_Stop},Plex Media Player
return

~Media_Play_Pause::
ControlSend,,{Media_Play_Pause},Plex Media Player
return

I’ve been craving this for ages, and your fix works perfectly! thank you so much!

@TheMooDude said:
Nothing too complicated or anything. Hope it’s useful.

~Media_Next::
ControlSend,,{Media_Next},Plex Media Player
return

~Media_Prev::
ControlSend,,{Media_Prev},Plex Media Player
return

~Media_Stop::
ControlSend,,{Media_Stop},Plex Media Player
return

~Media_Play_Pause::
ControlSend,,{Media_Play_Pause},Plex Media Player
return

Works perfectly. Now to have this built-in to PMP. Thanks!

@TheMooDude said:
Nothing too complicated or anything. Hope it’s useful.

~Media_Next::
ControlSend,,{Media_Next},Plex Media Player
return

~Media_Prev::
ControlSend,,{Media_Prev},Plex Media Player
return

~Media_Stop::
ControlSend,,{Media_Stop},Plex Media Player
return

~Media_Play_Pause::
ControlSend,,{Media_Play_Pause},Plex Media Player
return

Hey, i’m having a problem with your script. I have made the .ahk file (since your onedrive link was down) and ran the script, however nothing happens when I hit my media keys.

@aaronth07 said:
Hey, i’m having a problem with your script. I have made the .ahk file (since your onedrive link was down) and ran the script, however nothing happens when I hit my media keys.

Still works for me. Using AHK 1.1.26.01 on Windows 7 Ultimate x64.
Are you familiar with AHK? There’s a help file which helps with running your first script.

Also, do the media keys work in the first place, when PMP is in-focus?

@elvisman113 said:

@aaronth07 said:
Hey, i’m having a problem with your script. I have made the .ahk file (since your onedrive link was down) and ran the script, however nothing happens when I hit my media keys.

Still works for me. Using AHK 1.1.26.01 on Windows 7 Ultimate x64.
Are you familiar with AHK? There’s a help file which helps with running your first script.

I’m not that familiar with AHK, I just followed the tutorial to create your own script and pasted his code in there.

@elvisman113 said:
Also, do the media keys work in the first place, when PMP is in-focus?

Yeah, they do. It also seems that with PlexAmp the media keys work perfectly whether it is in focus or not.

I know this is an old thread and all, but the media keys still don’t work when PMP is not in focus. Have they said anything about implementing support for this since the last answer in here?

I have not been able to find much info on this anywhere else but this thread.

There’s a thread in the Feature Request subforum on this. Head over there and Like the first post to “vote” for it as an issue:

@aaronth07 said:
Yeah, they do. It also seems that with PlexAmp the media keys work perfectly whether it is in focus or not.
The AHK script uses the title of the PMP window as the target to send media commands to. Does your PMP instance have the same window title, “Plex Media Player”, as in the script? Don’t know what else to check, as it’s a pretty simple script.

@elvisman113 said:
There’s a thread in the Feature Request subforum on this. Head over there and Like the first post to “vote” for it as an issue:
https://forums.plex.tv/discussion/279226/plex-media-player-media-control-keys-support-while-not-focused-active

@elvisman113 said:

@aaronth07 said:
Yeah, they do. It also seems that with PlexAmp the media keys work perfectly whether it is in focus or not.
The AHK script uses the title of the PMP window as the target to send media commands to. Does your PMP instance have the same window title, “Plex Media Player”, as in the script? Don’t know what else to check, as it’s a pretty simple script.

I just tried the AHK script and it works pretty much perfectly. Theres a few places where it’s a bit iffy, but overall it works nicely.
I am still wondering if they are going to implement the feature “for real” though. It seems kinda silly that it does not support this by now imo.

I tried clicking your link but it looks like I don’t have access to that part of the site sadly.

I actually got the script to work, but now (when in focus) the pause/play key (and possibly the other media keys) no longer works. Not that big of a deal since when out of focus the media keys seem to work pretty well.

@aaronth07 said:
I actually got the script to work, but now (when in focus) the pause/play key (and possibly the other media keys) no longer works. Not that big of a deal since when out of focus the media keys seem to work pretty well.

You can fix this with a simple change to the script to only send the command when the window is inactive. Otherwise the pause key is registered twice, which is why the key doesn’t work.

~Media_Next::
IfWinNotActive, Plex Media Player
{
    ControlSend,,{Media_Next},Plex Media Player
}
return

~Media_Prev::
IfWinNotActive, Plex Media Player
{
ControlSend,,{Media_Prev},Plex Media Player
}
return

~Media_Stop::
IfWinNotActive, Plex Media Player
{
ControlSend,,{Media_Stop},Plex Media Player
}
return

~Media_Play_Pause::
IfWinNotActive, Plex Media Player
{
ControlSend,,{Media_Play_Pause},Plex Media Player
}
return
1 Like

UPDATE: As of August 2019, this AHK script is no longer necessary. Plex appears to be able to receive media hotkeys natively now! (Thanks to BlayZin for the heads-up).

The AutoHotkey script above stopped working for me recently on Windows 10 v1803 (build 17134.81). Don’t know if it was a change in AHK (currently v1.1.29.01) or Windows that caused the script to not work, but it appears that Plex Media Player was not properly receiving the commands. I updated the script to target the ahk_parent Control and the PlexMediaPlayer.exe application, and that seems to have fixed all of the issues on my system.

#NoEnv
#NoTrayIcon
SendMode Input

; Send media key inputs to Plex when it is available and isn't the focused application
#IfWinExist, ahk_exe PlexMediaPlayer.exe
#IfWinNotActive, ahk_exe PlexMediaPlayer.exe

~Media_Next::
    ControlSend, ahk_parent, {Media_Next}, ahk_exe PlexMediaPlayer.exe
return

~Media_Prev::
    ControlSend, ahk_parent, {Media_Prev}, ahk_exe PlexMediaPlayer.exe
return

~Media_Stop::
    ControlSend, ahk_parent, {Media_Stop}, ahk_exe PlexMediaPlayer.exe
return

~Media_Play_Pause::
    ControlSend, ahk_parent, {Media_Play_Pause}, ahk_exe PlexMediaPlayer.exe
return

#IfWinNotActive
#IfWinExist

Hi
I’m not familar with AHK and i have the same issue as you all.
Could you detail the all process to do this work please ?
Thanks by advance

It’s really pretty simple, actually. Go to https://autohotkey.com/ to download and install the AutoHotKey application. Note that AHK doesn’t really have a user interface of its own – all it does is launch/run scripts that you load by double-clicking them.

Once you have the host application installed:

  • Copy/paste the text from the code block in my post above into a new text document using Notepad.exe. Be sure to get everything, including the #NoEnv and final #IfWinExist lines (even though they’re marked as ‘comments’ in the forum styling, they’re actually important).
  • Save it as something like Plex Media Keys.ahk on your Desktop. Be sure to use the .ahk file extension so that AutoHotKey knows to run it.
  • Now, if you double-click the AHK file, it will launch an instance of AutoHotKey with those hotkeys enabled. Your media keys should now control Plex if it’s running.

If this is working well for you, you can add it to your Startup items:

  • Hit Win-R (to open the Run window), and type shell:startup to open your Startup Items folder.
  • Copy/paste the AHK file into that folder.
  • Now when you reboot, the script will automatically be loaded.

Hope that helps!

3 Likes

Hi
Thank you for your answer and sorry for the looooooooooong time in my response :wink:
I follow exactly your instructions and it works fine for the next and previous key only when Plex is focus. The play/pause key is not working at all on the other side.

Do you have any idea the reason for ?

I’m using a Logitech K800 Keyboard by the way, don’t know if it’s relevant

Edit : My bad, in fact keys work pretty fine with autokey if Plex is focus but only for a very short time ! After few seconds, keys don’t respond at all
Autokey doesn’t change a thing :frowning: Didn’t work at all, sorry

Regards

@beornlake That script is working well.

Here is one more issue the media keys stop working when using a Remote Desktop Session. I assume that this is because windows passes the keystrokes to the Remote Computer before AutoHotKey has a chance to see them.

I do not think there is anything that can be done about this but I would be very happy if someone proved me wrong.