First: I have written a script that can launch the Slacker Radio interface or the Pandora radio interface ( <!-- m -->http://pandora.com<!-- m --> ) and strips away the window chrome, turning it into a sort of floating widget. It requires Chrome, because Chrome has an easy command line option that removes all the toolbars etc and designates it as an "app". I just remove the title menu and borders. It has dragging code I grabbed from one of the example scripts on the AHK site, so you can move it around.
Screenshots!
<!-- m -->http://drop.io/Slack...e/asset/one-png<!-- m -->
<!-- m -->http://drop.io/Slack...e/asset/two-png<!-- m --> (mini-mode)
<!-- m -->http://drop.io/Slack...asset/three-jpg<!-- m --> (remote control on an ipod. Yes, it's ugly, feel free to come up with something prettier)
Second: It has hotkeys that let you control it. They just use ControlClick to press the buttons in the window, so it's a bit fragile and will break if the interface changes. It's a lot easier than any other solution, though.
Third: I've bastardized a python script I found online to let you remote control the interface. It uses python's built-in webserver library. Basically, you navigate to the.url.here:port/something and it executes something.ahk if it exists. It doesn't yet let those scripts return a value, because I didn't need it to, but that's not hard to add. This is easily extendable to controlling all sorts of things. This is great if you have something like an ipod touch- anything with a browser and an internet connection will let you control it.
Installation:
- If you just want parts 1) and 2), just drop the following script into a .ahk and run it. If it can't find your Chrome executable... which it won't, if you're not on Windows 7 (or Vista?) just replace that part in the line beginning "Run, " with the actual path. (Is there a better way to do this?)
- Set the hotkeys to your liking. You probably don't like mine. As it comes, this is what you get:
- Play/pause: ctrl-Q
- Next: ctrl-P
- "heart"/like: ctrl-1 (not on Pandora quite yet)
- roll up: ctrl-E
For Slacker Radio:
; ; AutoHotkey Version: 1.x ; Language: English ; Platform: Win9x/NT ; Author: A.N.Other <[email protected]> ; ; Script Function: ; Template script (you can customize this template by editing "ShellNew\Template.ahk" in your Windows folder) ; #SingleInstance force #WinActivateForce #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. Run, C:\Users\%A_UserName%\AppData\Local\Google\Chrome\Application\chrome.exe --app=http://www.slacker.com/webplayer/index_embed.vm WinWait, Web Player,,5 SetTitleMatchMode, Slow DetectHiddenText, On CoordMode, Mouse, Relative WinGet, the_id,ID,,http://www.slacker.com/webplayer/index_embed.vm ;WinSet,Style,-0x40000,ahk_id %the_id% WinSet,Style,-0xC40000,ahk_id %the_id% ; Remove the title bar WinMove, ahk_id %the_id%,, 0, 0, 680,580 WinSet, Region, 0-1 W650 H500 R9-9,ahk_id %the_id% snapped := 0 SmallMode := 0 slideSpeed := 20 FileDelete, scripts\winID.txt FileAppend, %the_id%,scripts\winID.txt ^q:: ;Play/pause ControlClick, x130 y70,ahk_id %the_id% return ^p:: ; next ControlClick, x200 y70,ahk_id %the_id% return ^1:: ; "Heart" ControlClick, x250 y70,ahk_id %the_id% return ~^e:: ; roll up IfWinActive, ahk_id %the_id% { if SmallMode = 0 { SmallMode := 1 n := 500 Loop { n := n-20 WinSet, Region, 0-1 W650 H%n% R9-9,ahk_id %the_id% if n<=107 { WinSet, Region, 0-1 W650 H87 R9-9,ahk_id %the_id% return } } } else { SmallMode := 0 m := 87 Loop { m := m+20 WinSet, Region, 0-1 W650 H%m% R9-9,ahk_id %the_id% if m>=480 { WinSet, Region, 0-1 W650 H500 R9-9,ahk_id %the_id% return } } } } return ~LButton:: CoordMode, Mouse ; Switch to screen/absolute coordinates. MouseGetPos, EWD_MouseStartX, EWD_MouseStartY, EWD_MouseWin test := EWD_MouseWin - the_id if test=0 { WinGetPos, EWD_OriginalPosX, EWD_OriginalPosY,,, ahk_id %EWD_MouseWin% SetTimer, EWD_WatchMouse, 10 ; Track the mouse as the user drags it. } return ToBase(n,b) { ; n >= 0, 1 < b <= 36 Return (n < b ? "" : ToBase(n//b,b)) . ((d:=mod(n,b)) < 10 ? d : Chr(d+55)) } EWD_WatchMouse: GetKeyState, EWD_LButtonState, LButton, P if EWD_LButtonState = U ; Button has been released, so drag is complete. { SetTimer, EWD_WatchMouse, off return } GetKeyState, EWD_EscapeState, Escape, P if EWD_EscapeState = D ; Escape has been pressed, so drag is cancelled. { SetTimer, EWD_WatchMouse, off WinMove, ahk_id %EWD_MouseWin%,, %EWD_OriginalPosX%, %EWD_OriginalPosY% return } ; Otherwise, reposition the window to match the change in mouse coordinates ; caused by the user having dragged the mouse: CoordMode, Mouse MouseGetPos, EWD_MouseX, EWD_MouseY WinGetPos, EWD_WinX, EWD_WinY,w_act,h_act, ahk_id %EWD_MouseWin% SetWinDelay, -1 ; Makes the below move faster/smoother. MoveToX := EWD_WinX + EWD_MouseX - EWD_MouseStartX MoveToY := EWD_WinY + EWD_MouseY - EWD_MouseStartY WinMove, ahk_id %EWD_MouseWin%,, MoveToX,MoveToY ;Sleep, 100 EWD_MouseStartX := EWD_MouseX ; Update for the next timer-call to this subroutine. EWD_MouseStartY := EWD_MouseY return
For Pandora radio:
; ; AutoHotkey Version: 1.x ; Language: English ; Platform: Win9x/NT ; Author: A.N.Other <[email protected]> ; ; Script Function: ; Template script (you can customize this template by editing "ShellNew\Template.ahk" in your Windows folder) ; #SingleInstance force #WinActivateForce #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. Run, C:\Users\%A_UserName%\AppData\Local\Google\Chrome\Application\chrome.exe --app=https://www.pandora.com/radio/tuner_9_0_0_0_pandora.swf WinWait, Web Player,,5 SetTitleMatchMode, Slow DetectHiddenText, On CoordMode, Mouse, Relative WinGet, the_id,ID,,https://www.pandora.com/radio/tuner_9_0_0_0_pandora.swf ;WinSet,Style,-0x40000,ahk_id %the_id% WinSet,Style,-0xC40000,ahk_id %the_id% ; Remove the title bar WinMove, ahk_id %the_id%,, 0, 0, 680,580 WinSet, Region, 16-79 W610 H241 R16-16,ahk_id %the_id% snapped := 0 SmallMode := 0 slideSpeed := 20 FileDelete, scripts\winID.txt FileAppend, %the_id%,scripts\winID.txt ^q:: ;Play/pause ControlSend,,{SPACE},ahk_id %the_id% return ^p:: ; next ControlSend,,{RIGHT},ahk_id %the_id% return ^r:: ; "Heart" ControlSend,,{+},ahk_id %the_id% return ~^e:: ; roll up IfWinActive, ahk_id %the_id% { if SmallMode = 0 { SmallMode := 1 WinSet, Region, 460-79 W166 H241 R16-16,ahk_id %the_id% } else { SmallMode := 0 WinSet, Region, 16-79 W610 H241 R16-16,ahk_id %the_id% } } return ~LButton:: CoordMode, Mouse ; Switch to screen/absolute coordinates. MouseGetPos, EWD_MouseStartX, EWD_MouseStartY, EWD_MouseWin test := EWD_MouseWin - the_id if test=0 { WinGetPos, EWD_OriginalPosX, EWD_OriginalPosY,,, ahk_id %EWD_MouseWin% SetTimer, EWD_WatchMouse, 10 ; Track the mouse as the user drags it. } return ToBase(n,b) { ; n >= 0, 1 < b <= 36 Return (n < b ? "" : ToBase(n//b,b)) . ((d:=mod(n,b)) < 10 ? d : Chr(d+55)) } EWD_WatchMouse: GetKeyState, EWD_LButtonState, LButton, P if EWD_LButtonState = U ; Button has been released, so drag is complete. { SetTimer, EWD_WatchMouse, off return } GetKeyState, EWD_EscapeState, Escape, P if EWD_EscapeState = D ; Escape has been pressed, so drag is cancelled. { SetTimer, EWD_WatchMouse, off WinMove, ahk_id %EWD_MouseWin%,, %EWD_OriginalPosX%, %EWD_OriginalPosY% return } ; Otherwise, reposition the window to match the change in mouse coordinates ; caused by the user having dragged the mouse: CoordMode, Mouse MouseGetPos, EWD_MouseX, EWD_MouseY WinGetPos, EWD_WinX, EWD_WinY,w_act,h_act, ahk_id %EWD_MouseWin% SetWinDelay, -1 ; Makes the below move faster/smoother. MoveToX := EWD_WinX + EWD_MouseX - EWD_MouseStartX MoveToY := EWD_WinY + EWD_MouseY - EWD_MouseStartY WinMove, ahk_id %EWD_MouseWin%,, MoveToX,MoveToY ;Sleep, 100 EWD_MouseStartX := EWD_MouseX ; Update for the next timer-call to this subroutine. EWD_MouseStartY := EWD_MouseY return
If you want part 3), it's a little bit more complicated, and I don't know if it will work everywhere, YMMV, only tested on my computer, etc etc. It also doesn't work with Pandora just yet. You can do it yourself- replace SlackerControl with PandoraControl, and grab the code under the various hotkey tags and put that in their respective mini ahk files under /scripts.
1- Install Python 2.6.5 (not 3.0. Yes, this script could be rewritten for 3.0 probably. They'll coexist on the same computer relatively happily if you already have 3.0 installed).
<!-- m -->http://www.python.or...releases/2.6.5/<!-- m -->
2- Download the python script & the helper ahk scripts here: http://drop.io/Slack...lackerremote-7z. Includes SlackerControl.ahk. Extract into a folder somewhere.
3- Find your local ip address.
Go to start->run-> type cmd and press enter
type ipconfig at the prompt and press enter
Scroll up until you see something like "Wireless LAN adapter Wireless network connection" and "Ethernet adapter Local Area Connection". Depending on whether you're connected wirelessly or wired, there will be an ip address under one of those two headings after "IPv4 address...". That's your computer's local ip address, and is what you will type into the browser of the "remote" device if you're on the same network. In my case, it's 192.168.0.75.
3b. If you want to access the webserver from another network (ie, away from home) you'll need to open a port (see below) in your router. Google "port forwarding" plus the brand and model of your router for a how-to.
4. Edit server.py in notepad, and replace the SERVERIP address with yours. There's almost certainly a way for python to determine this itself, but I haven't looked yet. Also, note the port (8080). You could run this on port 80 (the standard http port) to make things a little easier. For me, I type <!-- m -->http://192.168.0.75/<!-- m -->
5- Double click SlackerControl.ahk and wait for everything to load
6- Double click "Start Server", and agree to whatever XP/Vista/7 UAC/firewall prompts show up. Possibly clicking server.py will work just as well, unless you have Python 3.0 already installed and it's taken over the file association. You should get a happy "serving at port 8080" if everything's good.
7- Prove it works by going to <!-- m -->http://192.168.0.75:8080/<!-- m --> (with your actual ip address) from your server computer, then from your remote device.