Created
June 4, 2012 20:35
-
-
Save pckujawa/2870718 to your computer and use it in GitHub Desktop.
Hotkey controls for various music services (Pandora, Napster, Spotify, etc)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; | |
;#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. | |
;SendMode Input ; Recommended for new scripts due to its superior speed and reliability. | |
;SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. | |
; | |
; ############## Pandora ############## | |
; Ctrl+Forward -> next song | |
; Play/Pause -> play/pause | |
; | |
; | |
#SingleInstance | |
menu, tray, Icon, %A_ScriptDir%\pandora-shortcut.ico | |
Gosub,TRAYMENU | |
NapsterWindow = ahk_class #32770 | |
PandoraWindow = ahk_class ApolloRuntimeContentWindow | |
; might need to http://www.autohotkey.com/docs/commands/SetTitleMatchMode.htm | |
PandoraBrowserWindow = Pandora | |
SpotifyWindow = ahk_class SpotifyMainWindow | |
DetectHiddenWindows , On | |
;Hotkey, ^Browser_Forward, PandoraNext | |
;Hotkey, SC119, PandoraNext | |
Hotkey, Media_Play_Pause, PandoraPause | |
Hotkey, SC122, PandoraPause ; Play/Pause button on laptop? | |
Hotkey, Pause, PandoraPause | |
; Volume_Down | |
^SC12E:: | |
ControlSend , ahk_parent, {-}, Pandora ahk_class ApolloRuntimeContentWindow | |
return | |
; Volume_Up | |
^SC130:: | |
ControlSend , ahk_parent, {+}, Pandora ahk_class ApolloRuntimeContentWindow | |
return | |
; Calc key | |
SC121::#G | |
return | |
Hotkey, ^SC121, PandoraActivate | |
PandoraActivate: | |
WinActivate , ahk_class ApolloRuntimeContentWindow | |
;ControlSend , ahk_parent, {}, Pandora ahk_class ApolloRuntimeContentWindow | |
return | |
;#SC121:: | |
;ControlClick, ahk_class Messaging, , , RIGHT | |
;return | |
return | |
PandoraNext: | |
GoSub, NapsterMiniNext | |
DetectHiddenWindows, Off | |
IfWinExist, %PandoraWindow% | |
{ | |
ControlSend , ahk_parent, {right}, Pandora %PandoraWindow% | |
} | |
; Spotify detects my laptop's next key already | |
; else IfWinExist, %SpotifyWindow% | |
; { | |
; ; Click at x=90 y=780 for next | |
; ControlSend, ahk_parent, {^right}, Spotify %SpotifyWindow% | |
; } | |
else | |
GoSub, NapsterMiniNext | |
DetectHiddenWindows, On | |
;ControlSend , ahk_parent, {right}, Pandora ahk_class ApolloRuntimeContentWindow | |
return | |
PandoraPause: | |
DetectHiddenWindows, Off | |
IfWinExist, %PandoraWindow% | |
{ | |
ControlSend , ahk_parent, {space}, Pandora %PandoraWindow% | |
} | |
else IfWinExist, %PandoraBrowserWindow% | |
{ | |
;WinActivate | |
;WinWaitActive | |
; Send the space directly to the underlying player | |
ControlSend, Chrome_RenderWidgetHostHWND1, {space} | |
} | |
else IfWinExist, %SpotifyWindow% | |
{ | |
; Click at x=60 y=780 for play/pause | |
ControlSend, ahk_parent, {space}, Spotify %SpotifyWindow% | |
} | |
else | |
GoSub, NapsterMiniPausePlay | |
DetectHiddenWindows, On | |
return | |
NapsterMiniPausePlay: | |
IfWinExist, %NapsterWindow% | |
{ | |
ControlClick, Play | |
; WinWait, ahk_class #32770, | |
; IfWinNotActive, , , WinActivate, , | |
; WinWaitActive, , | |
; MouseClick, left, 72, 120 | |
} | |
return | |
NapsterMiniPrevious: | |
IfWinExist, %NapsterWindow% | |
{ | |
ControlClick, Prev | |
} | |
return | |
NapsterMiniNext: | |
IfWinExist, %NapsterWindow% | |
{ | |
ControlClick, "Next" | |
} | |
return | |
;MsgBox, test | |
ZunePausePlay: | |
ControlSend, ahk_parent, {TODO}, Zune ahk_class UIX Render Window | |
return | |
; ___ double click to enable/disable ____ | |
; The tray and swap code was taken from DragKing | |
; It allows you to double-click the icon to suspend the script, | |
; meaning that it will not run. There is also a checkbox in | |
; the tray that says whether or not the app is running | |
TRAYMENU: | |
Menu,Tray,Add,&Enabled,SWAP | |
Menu,Tray,Default,&Enabled | |
Menu,Tray,Check,&Enabled | |
Return | |
SWAP: | |
Menu,Tray,ToggleCheck,&Enabled | |
Suspend,Toggle | |
Return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm no AHK expert, so this script is hobbled together from examples and other scripts. It works for me with the pandora website as well as the pandora one gadget, spotify, etc. (I don't use zune or napster any more, so they haven't been tested lately.)