3

I'm using the following script which does not produce errors, but also does not work I'm afraid:

if WinActive("ahk_exe wmplayer.exe") or WinActive("ahk_exe Spotify.exe")
{
  Left::Send {RCtrl}{Left}
  Right::Send {RCtrl}{Right}
}

The idea is, that pressing a key arrow when WMP (Windows Media Player) has focus, the global shortcut (RCtrl+Arrow) should be triggered, which is defined in PowerToys for Prev/Next Track. The global shortcut works, but not (yet) via Autohotkey...

The console output seems to be correct?

---- M:\Software\Standalone\Apps.ahk
001: if WinActive("ahk_exe wmplayer.exe") || WinActive("ahk_exe Spotify.exe")  
006: Exit (14.50)
004: Send,{RCtrl}{Right} (0.03)
004: Return (2.41)
Cyman
  • 565
  • 1
  • 7
  • 22

1 Answers1

2

You could skip the PowerToys part entirely and just bind to MediaPrev and MediaNext:

if WinActive("ahk_exe wmplayer.exe") or WinActive("ahk_exe Spotify.exe")
{
  Left::Send {Media_Prev}
  Right::Send {Media_Next}
}

See docs for more info.

Or something like:

#If WinActive("ahk_exe wmplayer.exe") || WinActive("ahk_exe Spotify.exe")
Left::Send {Media_Prev}
Right::Send {Media_Next}

If you'd like for the bindings to only work in those apps.

Destroy666
  • 12,350