Example:
MyPlay/PauseButton:: ; For completeness. IfWinExist, %FoobClass% { IfWinNotActive,%FoobClass% { ControlSend,ahk_parent,{Media_Play_Pause} Return } Send, {Media_Play_Pause} } ReturnWhen the window is inactive, the ControlSend commad doesn't work.
When active, the Send command does.
I can ControlSend other key combinations.
In this example, "c" tells Foobar to "play" and does, when minimized or behind another window.
IfWinExist, %FoobClass% { IfWinNotActive,%FoobClass% { ControlSend,ahk_parent,c Return } Send, {Media_Play_Pause} } Return
This is what I am using now, but I don't like the fact that Foobar flashes onscreen every time I want to pause it.
IfWinExist, %FoobClass% { IfWinNotActive,%FoobClass% { WinActivate Send, {Media_Play_Pause} WinMinimize Return } Send, {Media_Play_Pause} } ReturnAny thoughts or suggestions will be very much appreciated.
Thanks.