I use
AutoHotkey to accomplish this. AutoHotkey is a free, open-source utility for Windows that allows you to automate just about anything. You can use the AutoScriptWriter (Recorder) to get the exact mouse click positions.
Here's my script:
- Code: Select all
#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.
SetTitleMatchMode 3 ; A window's title must exactly match Subsonic to be a match.
Media_Next::
WinWait, Subsonic
IfWinNotActive, Subsonic, , WinActivate, Subsonic,
WinWaitActive, Subsonic,
WinMaximize, Subsonic
MouseClick, left, 777, 780
Sleep, 100
Return
Media_Prev::
WinWait, Subsonic,
IfWinNotActive, Subsonic, , WinActivate, Subsonic,
WinWaitActive, Subsonic,
WinMaximize, Subsonic
MouseClick, left, 764, 780
Sleep, 100
Return
Media_Stop::
WinWait, Subsonic,
IfWinNotActive, Subsonic, , WinActivate, Subsonic,
WinWaitActive, Subsonic,
WinMaximize, Subsonic
MouseClick, left, 431, 780
Sleep, 100
Return
Media_Play_Pause::
WinWait, Subsonic,
IfWinNotActive, Subsonic, , WinActivate, Subsonic,
WinWaitActive, Subsonic,
WinMaximize, Subsonic
MouseClick, left, 415, 780
Return
Couple of notes:
* I used Google Chrome to create an
Application Shortcut, and the window title contains only "Subsonic" (without the "quotes"). The SetTitleMatchMode 3 line forces AutoHotkey to only find and maximize windows that have a title that's exactly "Subsonic". In Internet Explorer the title is "Subsonic - Windows Internet Explorer", so if I use IE for Subsonic I'd have to change all of the "Subsonic" instances in the script to "Subsonic - Windows Internet Explorer". I had to include this because if I had the Subsonic forums open in IE and don't have SetTitleMatchMode 3 in the script, AutoHotkey would mistake the IE window (which has "Subsonic..." in the title) for the actual Subsonic window. There's probably a better way to make sure the script clicks on the correct window, but this works good enough for me.
* My display is set to a resolution of 1920 x 1024. If this script was on a computer with a different resolution (or if the browser's zoom was different) the mouse click positions would need to change. You can easily find the positions with the AutoScriptWriter (Recorder) that is installed with AutoHotkey.
* I've programmed the script to only use the previous, next, play/pause, and stop buttons on my keyboard, but some keyboards have other "extra" buttons (such as Media Launch - which could be programmed to open a browser to your Subsonic installation). AutoHotkey recognizes the following extra buttons:
Browser_Back
Browser_Forward
Browser_Refresh
Browser_Stop
Browser_Search
Browser_Favorites
Browser_Home
Volume_Mute
Volume_Down
Volume_Up
Media_Next
Media_Prev
Media_Stop
Media_Play_Pause
Launch_Mail
Launch_Media
Launch_App1
Launch_App2
* You can set any key (or combination of keys) as hotkeys. For example, if you change
- Code: Select all
Media_Play_Pause::
to
- Code: Select all
#n::
AutoHotkey will click on the play/pause button on the Subsonic window if you press the Windows and n buttons at the same time.
* AutoHotkey comes with a great help file that's full of examples, and there's a lot more in the
forums.