         ; WinMinimize, ahk_exe spotify.exe
         ; WinActivate, wintit
 
-        ; System wide Play/Pause seems to work but it activates foobar2000 too
-        Send {Media_Play_Pause}
+        ; Syntax:
+        ;   PostMessage, Msg, wParam,  lParam, Control, WinTitle
+        ;
+        ;   Send the WM_APPCOMMAND message, 0x319. Details about that message: https://msdn.microsoft.com/en-us/library/windows/desktop/ms646275(v=vs.85).aspx
+        ;   APPCOMMAND_MEDIA_PLAY_PAUSE = 0xE0000
+        ;   APPCOMMAND_MEDIA_PLAY_PAUSE = 14 = 0xE0000 somehow
+        ;   APPCOMMAND_MEDIA_NEXTTRACK = 11 = 0xB0000 somehow
+        ;   APPCOMMAND_MEDIA_PREVIOUSTRACK = 12 = 0xC0000 somehow
+        PostMessage, 0x319, , 0xE0000, , ahk_exe Spotify.exe
 
         ; Doesn't work with latest spotify update
         ; ControlSend, ahk_parent, {Space}, ahk_class SpotifyMainWindow ; Pause/Unpause

;   `ahk_class SpotifyMainWindow` doesn't work so I had to replace it temporarily
;   with `ahk_exe Spotify.exe`
;   Reported here: https://community.spotify.com/t5/Ongoing-Issues/Windows-Desktop-app-now-uses-default-chrome-class-name/idi-p/4409722

; ctrl + shift + p = play/pause in Spotify
$^+p::

    IfWinExist ahk_exe Spotify.exe
    {
        ; ControlSend, ahk_parent, ^{Left}, ahk_class SpotifyMainWindow
        ; ControlSend, ahk_parent, ^{Left}

        PostMessage, 0x319, , 0xC0000, , ahk_exe Spotify.exe ; Previous track

        Tooltip, Spotify Previous Song
    }
    else
