Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Slacker & Pandora Internet Radio: Mini interface


  • Please log in to reply
14 replies to this topic
BungaDunga
  • Members
  • 7 posts
  • Last active: Apr 03 2010 06:07 PM
  • Joined: 03 Apr 2006
This is still a work in progress, but I thought I'd share because I'm rather pleased with it.

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.

BungaDunga
  • Members
  • 7 posts
  • Last active: Apr 03 2010 06:07 PM
  • Joined: 03 Apr 2006
I gather nobody is interested at all? I've another version for Pandora I could put up, if anyone wants.

LiquidGravity
  • Members
  • 156 posts
  • Last active: Oct 11 2014 04:11 PM
  • Joined: 26 Jan 2009
Please do add the Pandora version. Pandora is my steaming radio of choice.

I (and possibly others) have never heard of Slacker Radio, so I thought this was an mp3 player for lazy people - which there seems to be a new one of every couple weeks. Perhaps add "steaming internet" to the title between "Slacker Radio" and more people will notice it.

BungaDunga
  • Members
  • 7 posts
  • Last active: Apr 03 2010 06:07 PM
  • Joined: 03 Apr 2006

Please do add the Pandora version. Pandora is my steaming radio of choice.

I (and possibly others) have never heard of Slacker Radio, so I thought this was an mp3 player for lazy people - which there seems to be a new one of every couple weeks. Perhaps add "steaming internet" to the title between "Slacker Radio" and more people will notice it.


Ah. Good point, thanks- and done.

LiquidGravity
  • Members
  • 156 posts
  • Last active: Oct 11 2014 04:11 PM
  • Joined: 26 Jan 2009
The Pandora version works great. I had to login with a normal browser window first though. Also I tweaked the clipping regions to fit a little better and had it check if the window existed before starting a new one window.

LiquidGravity logged off
  • Guests
  • Last active:
  • Joined: --
One other change for the Pandora version. You must add {} brackets around the plus sign being sent to thumbs up a song or only a shift is sent.

BungaDunga
  • Members
  • 7 posts
  • Last active: Apr 03 2010 06:07 PM
  • Joined: 03 Apr 2006

One other change for the Pandora version. You must add {} brackets around the plus sign being sent to thumbs up a song or only a shift is sent.


Oh, that's why it wasn't working. Thanks!

derRaphael
  • Members
  • 872 posts
  • Last active: Mar 19 2013 04:42 PM
  • Joined: 23 Nov 2007
probly u may adapt the sparrow webserver which is written completly in ahk - as long as its only for remote control other apps thru web

u may find sparrow here: <!-- m -->http://www.autohotke...topic36047.html<!-- m -->

:)

greets
dR

All scripts, unless otherwise noted, are hereby released under CC-BY

BungaDunga
  • Members
  • 7 posts
  • Last active: Apr 03 2010 06:07 PM
  • Joined: 03 Apr 2006

probly u may adapt the sparrow webserver which is written completly in ahk - as long as its only for remote control other apps thru web

u may find sparrow here: <!-- m -->http://www.autohotke...topic36047.html<!-- m -->

:)

greets
dR


Oh, neat. I'll check it out, thanks!

I've made another version of the Slacker script that will show the song playing on the remote control webpage. I'll put it up here soonish.

schnarkle
  • Members
  • 50 posts
  • Last active: Oct 07 2015 03:07 PM
  • Joined: 21 May 2007
Just wanted to say nice work!

Using the slacker script now...

DeWild1
  • Members
  • 369 posts
  • Last active: Feb 28 2014 08:15 PM
  • Joined: 30 Apr 2006
I took it, and hacked the crap out of it. I tried to use COM and ahk web recorder.exe from the gOD Tank but I could not get stuff like
iWeb_getDomObj(pwb,"transport_skip")
to work so I had to stick with crap like
WinWait, Web Player,,10
sleep, 3000
     winactivate, ahk_id %the_id%
     WinGetTitle, ad, ahk_id %the_id%,
   ControlClick, x305 y266,ahk_id %the_id%
   WinMinimize, ahk_id %the_id%
Maybe someone could get it fully ported over to COM so it would be faster but I spent too much time on this, :roll: 8) 8) 8) but the cool part its skips songs you do not like, skips Advertisement, and does other stuff I like.
Step 1, go to <!-- w -->www.slacker.com<!-- w --> and make a free account. Play a station you like, then close the web page.
2. DL CoHelper.ahk com.ahk and iWeb.ahk from <!-- m -->http://www.autohotke...topic16631.html<!-- m --> and other places on this forum using SEARCH. Put them in same dir as the below script so it can be compiled.
3. run this. (ya, I know its ugly, but it works so stfu :lol: )
menu, tray, NoStandard   

Menu, Tray, add,
Menu, tray, add, Play-Pause also Win key + 1, p-p
Menu, Tray, add,
Menu, Tray, add, Skip song also Win key + 2, next
Menu, Tray, add,
Menu, Tray, add, Add an AD or a Song you do not like to the autoskip list also Win key + 3, ad
Menu, Tray, add,
Menu, tray, add, Exit, ex
Menu, Tray, Tip, Slacker Player with no ADs and autoskip!
#SingleInstance force
#WinActivateForce
ifnotexist, c:\temp\ads.txt
{
   msgbox, 0,  Slacker Player with no ADs and autoskip!,
(

Slacker Player with no ADs and autoskip!


Make sure you make a free account on Slacker.com BEFORE you click OK.

To use, remember...

To Play-Pause use Win key + 1 or Tray Menu.

To Skip song use Win key + 2 or Tray Menu.

To Add an AD or a Song you do not like to the autoskip list use Win key + 3 or Tray Menu.

)
FileCreateDir, c:\temp
fileappend,
(
Advertisement
webex
slacker

), c:\temp\ads.txt
}

fileinstall, iWeb.ahk, c:\temp\iWeb.ahk
fileinstall, CoHelper.ahk, c:\temp\CoHelper.ahk
fileinstall, com.ahk, c:\temp\com.ahk

#include c:\temp\CoHelper.ahk ; http://www.autohotkey.com/forum/topic16631.html
#Include c:\temp\com.ahk
#Include c:\temp\iWeb.ahk
SetWorkingDir %A_ScriptDir%  ; Ensures a onsistent starting directory.
onexit, ex
SetTimer, call, on ;just for my VOIP phone, so it stops playing when I get a call

url4 = http://www.slacker.com/webplayer/index_embed.vm


COM_CoInitialize()

   DOMAsText:=8
   pwb   :=   COM_CreateObject("InternetExplorer.Application")
   com_invoke(pwb,"silent")
   COM_Invoke(pwb , "Visible=", "True")
   nav(pwb,url4)
   complete(pwb)


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%
 sleep, 100
     
   WinMinimize, ahk_id %the_id%
   WinWait, Web Player,,10
sleep, 4000 ; you may need to play with this according to speed of your PC and internet connection.. Some fast computers can cut this down to 2000
     winactivate, ahk_id %the_id%
     WinGetTitle, ad, ahk_id %the_id%,
   ControlClick, x305 y266,ahk_id %the_id%
   WinMinimize, ahk_id %the_id%
   sleep, 5000
snapped := 0
SmallMode := 0
slideSpeed := 20

     
   SetTitleMatchMode, 1
loop,
{
sleep, 100

 Loop, read, c:\temp\ads.txt
{
      WinGetTitle, ad, ahk_id %the_id%,
      sleep, 100
 IfInString, ad, %A_LoopReadLine%
 {

   COM_Invoke(pwb, "Refresh2")
  complete(pwb)
   WinWait, Web Player,,10
sleep, 3000 ; you may need to play with this according to speed of your PC and internet connection
     winactivate, ahk_id %the_id%
     WinGetTitle, ad, ahk_id %the_id%,
   ControlClick, x305 y266,ahk_id %the_id%
    WinMinimize, ahk_id %the_id%
sleep, 15000
}
}






   }
p-p:
#1:: ;Play/pause
     winactivate, ahk_id %the_id%
ControlClick, x130 y160,ahk_id %the_id%
 WinMinimize, ahk_id %the_id%
return
next:
#2:: ; next
     winactivate, ahk_id %the_id%
ControlClick, x200 y160,ahk_id %the_id%
 WinMinimize, ahk_id %the_id%
return
ad:
#3:: ; "ad"
 
   WinGetTitle, ad, ahk_id %the_id%,
   StringSplit, ad, ad, -
   IfNotInString, ad1, Web Player
FileAppend, %ad1%`n,c:\temp\ads.txt
               
               
   COM_Invoke(pwb, "Refresh2")
  complete(pwb)
 WinMinimize, ahk_id %the_id%
   WinWait, Web Player,,10
sleep, 3000 ; you may need to play with this according to speed of your PC and internet connection
     winactivate, ahk_id %the_id%
     WinGetTitle, ad, ahk_id %the_id%,
   ControlClick, x305 y266,ahk_id %the_id%
    WinMinimize, ahk_id %the_id%
sleep, 15000

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:
sleep, 100
return

call: ;just for my VOIP phone, so it stops playing when I get a call
SetTimer, call, off
sleep, 50
IfWinActive, 3CXPhone
{
     winactivate, ahk_id %the_id%
ControlClick, x130 y160,ahk_id %the_id%
 WinMinimize, ahk_id %the_id%
}
SetTimer, call, 1000
Return

ex:

 
      pwb:=
winclose, ahk_id %the_id%
exitapp



clickbyval(pwb,t){
 If   i:=pwb ? com_invoke(pwb,"document.all.tags","input") :
   loop % com_invoke(i,"length")
      c:=InStr(com_invoke(i,"item[" A_Index-1 "].value"),t) ? (com_invoke(i,"item[" A_Index-1 "].click"),COM_Release(i),break) : 0
}
new()
{
   
 

 
   pwb   :=   COM_CreateObject("InternetExplorer.Application")
   COM_Invoke(pwb,   "Visible=",   "True") ;"False" ;"True" ;
   
 

 
   Return   pwb
   
 

 
}
;~ pwb(t)
;~ {
;~   
;~

;~
;~    Loop, %   COM_Invoke(psw := COM_Invoke(psh:=COM_CreateObject("Shell.Application"), "Windows"), "Count")
;~    {
;~     
;~

;~
;~       LocationName:=COM_Invoke(pwb:=COM_Invoke(psw, "Item", A_Index-1), "LocationName")
;~       IfInString,LocationName,%t%
;~          Break
;~       COM_Release(pwb),   VarSetCapacity(pwb,   0) ;didnt break so release the one we didnt use
;~    }
;~    COM_Release(psw),   VarSetCapacity(psw,   0),   COM_Release(psh),   VarSetCapacity(psh,   0)
;~    Return pwb is Integer   ?   pwb   :   "Error"
;~   
;~

;~
;~ }
pwin(pwb)
{
   
 

 
   IID_IHTMLWindow2   :=   "{332C4427-26CB-11D0-B483-00C04FD90119}"
   Return   COM_QueryService(pwb,   IID_IHTMLWindow2,   IID_IHTMLWindow2)
   
 

 
}

nav(pwb,url)
{
   
 

 
   HRESULT   :=   COM_Invoke(pwb,   "Navigate",   url,   0x0400,   "_self")
   If   HRESULT
      sleep, 1500 ;sleep, 1500 ;complete(pwb)   
   Return   HRESULT
   
 

 
}

sleep, 1500 ;sleep, 1500 ;complete(pwb)
{
 
loop 10
   If   (com_invoke(pwb,"readystate")<>4)
      break
   Else   sleep 200
loop 60
   If   (com_invoke(pwb,"readystate")=4)
      break
   Else   sleep 500
 
}
pdoc(pwb)
{
   
 

COM_Invoke(pwb,"document.all.item[80].click")
 
   Return   pwb ? (COM_Invoke(pw:=pwin(pwb),   "Document"),com_release(pw)) :
   
 

 
}

clickLnk(pwb,t)
{

 If   i:=pwb ? (com_invoke(pd:=pdoc(pwb),"links"),COM_Release(pd)) : {
   tag   :=   COM_Invoke(i,   "tagName")
   loop % com_invoke(i,"length")
      c:=InStr(com_invoke(i,InStr(tags,   tag)   ?   "value"   :   "innerHTML"),t) ? (com_invoke(i,"click"),COM_Release(i),break) : 0
  }
   sleep, 1500 ;sleep, 1500 ;complete(pwb)
   Return
}
complete(pwb)
{
 
loop 10
   If   (com_invoke(pwb,"readystate")<>4)
      break
   Else   sleep 200
loop 60
   If   (com_invoke(pwb,"readystate")=4)
      break
   Else   sleep 200
 
}


;~ clickObj(pwb,v)
;~ {
;~    tags   :=   "BUTTON,INPUT,OPTION,SELECT,TEXTAREA"
;~  If   i:=pwb ? (com_invoke(pd:=pdoc(pwb),"all"),COM_Release(pd)) : {
;~    tag   :=   COM_Invoke(i,   "tagName")
;~    loop % com_invoke(i,"length")
;~       c:=InStr(com_invoke(i,InStr(tags,   tag)   ?   "value"   :   "innerHTML"),t) ? (com_invoke(i,"click"),COM_Release(i),break) : 0
;~   }
;~    Return
;~   
;~

;~
;~ }

;~ setDom(pwb,obj,t)
;~ {
;~    tags   :=   "BUTTON,INPUT,OPTION,SELECT,TEXTAREA"
;~    Return pwb ? (com_invoke(pd:=pdoc(pwb),"all.item[" obj "]." InStr(tags,   tag)   ?   "value"   :   "innerHTML", t),COM_Release(pd))
;~ }



;iWeb_DomWin(pwb)
;{
 ;  IID_IHTMLWindow2      := "{332C4427-26CB-11D0-B483-00C04FD90119}"
;   Return            COM_QueryService(pwb,   IID_IHTMLWindow2,   IID_IHTMLWindow2)
;}

;new//////////////////////////////////////

SetTimeouts()
SetTimeouts(Resolve=0, Connect=60000, Send=30000, Receive=30000) {
  ; http://msdn2.microsoft.com/en-us/library/aa384061.aspx
  global pWHR
  DllCall(VTable(pWHR, 23), "Uint", pWHR, "Int", Resolve, "Int", Connect, "Int", Send, "Int", Receive)
}

;end//////////////////////////////
;//////////////////////////////////////////////////////////////////////////////
or you can use the one I compiled. <!-- w -->www.911pcfix.com/slacker.exe<!-- w -->

doctorbri
  • Members
  • 2 posts
  • Last active: Dec 31 2015 10:18 PM
  • Joined: 20 Sep 2010
I haven't dug through the code yet, just copy/pasted, but neither are working as they should (though I appreciate your hard work!). The slacker script brings up chrome, seems to initially work, then the site flashes and brings up the full webpage. Window edge is present, but no taskbars. The pandora works as advertised except the wrong part of the page is displayed. Fresh chrome install, windows 7.

doctorbri
  • Members
  • 2 posts
  • Last active: Dec 31 2015 10:18 PM
  • Joined: 20 Sep 2010
Alright, I was messing with the scripts tonight and am nearly there, but not quite and am looking for help.

1. Updated URLs: simply used pandora.com and slacker.com
2. Changed window names to

Slacker Personal Radio - Listen to Free Internet Radio Stations
Pandora Radio - Listen to Free Internet Radio, Find New Music

3. Changed window sizes for both scripts. I can't, however, seem to remove the scrollbars which keep showing up.

4. Could probably remove 'DetectHiddenText' now that I've changed the WinGet parameters.

Anyways, would someone review these and tell me what you think? I'm looking to clean these up for general use, probably also to use as portable apps, so to speak. I'm new at this, btw (if it wasn't yet obvious), so noob level help is needed. My main problem at this point are the scroll bars that won't go away. I googled for hex codes for them, WS_VSCROLL, etc, but no luck. Is there a way to query style codes on these things?

p.s. would love to somehow insert 'Pandora' into left upper hand of the window, but that's likely way over my head.

Changed areas highlighted in red

Pandora:

;
; 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=[color=red]https://www.pandora.com[/color]
WinWait, [color=red]Pandora Radio - Listen to Free Internet Radio, Find New Music[/color],,5

SetTitleMatchMode, [color=red]3[/color]
[color=red];[/color]DetectHiddenText, On
CoordMode, Mouse, Relative
WinGet, the_id,ID,,[color=red]Pandora Radio - Listen to Free Internet Radio, Find New Music[/color]
;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, [color=red]60-137 W610 H236 R20-20[/color],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, [color=red]494-137 W176 H236 R20-20[/color],ahk_id %the_id%
} else {
SmallMode := 0
WinSet, Region, [color=red]60-137 W610 H236 R20-20[/color],ahk_id %the_id%[/color]

}

}

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

Slacker:

;
; 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=[color=red]http://www.slacker.com[/color]
WinWait, [color=red]Slacker Personal Radio - Listen to Free Internet Radio Stations[/color],,5

SetTitleMatchMode, [color=red]3[/color]
[color=red];[/color]DetectHiddenText, On 
CoordMode, Mouse, Relative
WinGet, the_id,ID,,[color=red]Slacker Personal Radio - Listen to Free Internet Radio Stations[/color]
;WinSet,Style,-0x40000,ahk_id %the_id% ; [color=red]not sure what this removes, but doesn't seem to do anything[/color]
WinSet,Style,-0xC40000,ahk_id %the_id% ; Remove the title bar
WinMove, ahk_id %the_id%,, 0, 0, 680,580
WinSet, Region, 0-[color=red]152[/color] 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-[color=red]152[/color] W650 H%n% R9-9,ahk_id %the_id%

if n<=107
{
   WinSet, Region, 0-[color=red]152[/color] W650 H87 R9-9,ahk_id %the_id%
   return
}
}
} else {
SmallMode := 0
m := 87
Loop {
m := m+20
WinSet, Region, 0-[color=red]152[/color] W650 H%m% R9-9,ahk_id %the_id%

if m>=480
{
   WinSet, Region, 0-[color=red]152[/color] 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


Damein
  • Members
  • 296 posts
  • Last active: Nov 17 2011 07:37 PM
  • Joined: 27 Aug 2009
Sadly it doesn't seem to work for me.

A couple things you should mention is that in your code you have:

FileDelete, scripts\winID.txt
FileAppend, %the_id%,scripts\winID.txt

And unless that person already has the dir scripts it will not create the text document.

So if you want it this way you need to set it like this:

FileCreateDir, Scripts

I would set that at the location you set the working dir personally.

Either way, I don't have time at this moment to see why.. but it won't work for me.

I can have focus on the window and it still won't control it. I can press space and it pauses, but using Control+Q nothing happens.

Good luck! I'll look into it later :)

JoeSchmoe
  • Members
  • 304 posts
  • Last active: Feb 28 2013 05:39 PM
  • Joined: 17 Feb 2008
Would love to see this working and try it out once there is a polished version. I'm a pretty fanatical user of both Pandora and AHK, but I'm crazy busy, so don't have time to have fun, just hacking around with the code.