AutoHotkey Community

It is currently May 26th, 2012, 1:41 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 38 posts ]  Go to page 1, 2, 3  Next
Author Message
 Post subject: Spotify and AHK
PostPosted: December 8th, 2008, 4:12 pm 
First: I loooove spotify.

Second: It has some flaws. I would like to be able to:

1. Use the built in hotkeys without activating the window.
2. Maybe create a GUI that shows what son is currently playing.

Can stuff like this be done at all?

I'd appreciate any push in a good direction to get me started.

Cheers!


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: December 8th, 2008, 4:27 pm 
Offline
User avatar

Joined: November 2nd, 2008, 4:23 pm
Posts: 2906
Location: 127.0.0.1
Yes control send will work for this.
Heres the syntax:
Quote:
ControlSend [, Control, Keys, WinTitle, WinText, ExcludeTitle, ExcludeText]

And heres an example of how you would use it for hotkeys:

Code:
ControlSend, , ^p, Spotify

The first param is blank to send it to the window, then the hotkey to send then window title. The rest isn't that important for this.

_________________
aboutscriptappsscripts
Any code ⇈ above ⇈ requires AutoHotkey_L to run


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 8th, 2008, 6:06 pm 
ty!

got the most important hotkeys going now!


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: December 9th, 2008, 12:23 am 
trying to expand with a GUI that shows what is playing now.

Code:
F10::
{
WinGetTitle, now_playing, ahk_class SpotifyMainWindow
StringTrimLeft, playing, now_playing, 10
MsgBox, Now playing: %playing%
}


This retrieves the info I need, but how can I put this into a GUI that auto-updates itself instead of a messagebox?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: December 9th, 2008, 12:29 am 
Offline
User avatar

Joined: November 2nd, 2008, 4:23 pm
Posts: 2906
Location: 127.0.0.1
I recomend using traytip because its easy and can be seen in any window.

Heres an example of how to make a timed traytip:

AHK Help File wrote:
TrayTip, Timed TrayTip, This will be displayed for 5 seconds.
SetTimer, RemoveTrayTip, 5000
return

RemoveTrayTip:
SetTimer, RemoveTrayTip, Off
TrayTip
return


_________________
aboutscriptappsscripts
Any code ⇈ above ⇈ requires AutoHotkey_L to run


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 9th, 2008, 12:37 am 
I'll have a look into the TrayTip. Never heard of it before.

This is my latest effort:

Code:
SetTitleMatchMode 2

F12::ControlSend, , ^{Right}, Spotify
F11::ControlSend, , ^{Left}, Spotify

F10::
{
WinGetTitle, now_playing, ahk_class SpotifyMainWindow
StringTrimLeft, playing, now_playing, 10
Gui,+AlwaysOnTop
Gui, Add, Text,, %playing%
Gui, Show
}


It gets the title, but I cant get it to change when I play new songs, and the first two hotkeys wont work as long as the gui is up.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: December 9th, 2008, 12:55 am 
Code:
SetTimer, RefreshTrayTip, 1000
Gosub, RefreshTrayTip  ; Call it once to get it started right away.
return

RefreshTrayTip:
WinGetTitle, now_playing, ahk_class SpotifyMainWindow
StringTrimLeft, playing, now_playing, 10
TrayTip, Now playing:, %playing%., , 16
return


No matter what I do with the TrayTip function it only shows for a few milliseconds before it is closed.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: December 9th, 2008, 1:12 am 
Offline

Joined: December 9th, 2008, 1:09 am
Posts: 3
This works for me ...


Code:

; "WinKey + p"  for previous
#p::
DetectHiddenWindows, On
ControlSend, ahk_parent, ^{Left}, ahk_class SpotifyMainWindow
DetectHiddenWindows, Off
return


; "WinKey + n"  for next
#n::
{
DetectHiddenWindows, On
ControlSend, ahk_parent, ^{Right}, ahk_class SpotifyMainWindow
DetectHiddenWindows, Off
return
}

; "WinKey + q"  for pause
#q::
{
DetectHiddenWindows, On
ControlSend, ahk_parent, {Space}, ahk_class SpotifyMainWindow
DetectHiddenWindows, Off
return
}

; "WinKey + 3"  for info
#3::
{
DetectHiddenWindows, On
SetTitleMatchMode 2
WinGetTitle, now_playing, ahk_class SpotifyMainWindow
StringTrimLeft, playing, now_playing, 10
Gui,+AlwaysOnTop
Gui, Add, Text,, %playing%
Gui, Show
DetectHiddenWindows, Off
return
}



Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 9th, 2008, 1:40 am 
Are you sure it updates the GUI if you switch songs?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: December 9th, 2008, 1:56 am 
Offline

Joined: December 9th, 2008, 1:09 am
Posts: 3
No I see that that doesn't work ...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 9th, 2008, 2:03 am 
Offline

Joined: December 9th, 2008, 1:09 am
Posts: 3
Strange window update.
I used your example instead and added a test for song change ...

Code:
SetTimer, RefreshTrayTip, 1000
playingSave := ""
Gosub, RefreshTrayTip  ; Call it once to get it started right away.
return

RefreshTrayTip:
WinGetTitle, now_playing, ahk_class SpotifyMainWindow
StringTrimLeft, playing, now_playing, 10
if(playing != playingSave) {
  TrayTip, Now playing:, %playing%., , 16
}
playingSave := playing
return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 9th, 2008, 2:19 am 
this keeps the traytip up at all times:

Code:
SetTitleMatchMode 2

#Persistent
SetTimer, RefreshTrayTip, 1000
Gosub, RefreshTrayTip  ; Call it once to get it started right away.
return

F12::ControlSend, , ^{Right}, Spotify
F11::ControlSend, , ^{Left}, Spotify



RefreshTrayTip:
WinGetTitle, now_playing, ahk_class SpotifyMainWindow
StringTrimLeft, playing, now_playing, 10
TrayTip, Now playing:, %playing%., 29 , 16
return


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: December 9th, 2008, 2:27 am 
Offline

Joined: June 22nd, 2006, 7:58 pm
Posts: 6
getting there:

Code:
SetTitleMatchMode 2

#Persistent
SetTimer, RefreshTrayTip, 1000
playingsave := ""
Gosub, RefreshTrayTip  ; Call it once to get it started right away.
return

; "WinKey + p"  for previous
#p::
DetectHiddenWindows, On
ControlSend, ahk_parent, ^{Left}, ahk_class SpotifyMainWindow
DetectHiddenWindows, Off
return


; "WinKey + n"  for next
#n::
{
DetectHiddenWindows, On
ControlSend, ahk_parent, ^{Right}, ahk_class SpotifyMainWindow
DetectHiddenWindows, Off
return
}

RefreshTrayTip:
WinGetTitle, now_playing, ahk_class SpotifyMainWindow
StringTrimLeft, playing, now_playing, 10
if(playing != playingsave) {
  TrayTip, Now playing:, %playing%., 10 , 16 
}
playingsave := playing
return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 9th, 2008, 2:39 am 
Offline

Joined: June 22nd, 2006, 7:58 pm
Posts: 6
ok, happy with this for now :D

Code:
SetTitleMatchMode 2

#Persistent
SetTimer, RefreshTrayTip, 1000
playingsave := ""
Gosub, RefreshTrayTip  ; Call it once to get it started right away.
return

; "CTRL + LEFT"  for previous
^Left::
DetectHiddenWindows, On
ControlSend, ahk_parent, ^{Left}, ahk_class SpotifyMainWindow
DetectHiddenWindows, Off
return


; "CTRL + RIGHT"  for next
^Right::
{
DetectHiddenWindows, On
ControlSend, ahk_parent, ^{Right}, ahk_class SpotifyMainWindow
DetectHiddenWindows, Off
return
}

; "CTRL + UP"  for info
^Up::
{
DetectHiddenWindows, On
SetTitleMatchMode 2
WinGetTitle, now_playing, ahk_class SpotifyMainWindow
StringTrimLeft, playing, now_playing, 10
TrayTip, Now playing:, %playing%., 10 , 16
DetectHiddenWindows, Off
return
}

RefreshTrayTip:
WinGetTitle, now_playing, ahk_class SpotifyMainWindow
StringTrimLeft, playing, now_playing, 10
if(playing != playingsave) {
  TrayTip, Now playing:, %playing%., 10 , 16 
}
playingsave := playing
return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 4th, 2009, 4:33 am 
Offline

Joined: January 3rd, 2009, 11:11 am
Posts: 4
Thanks for the script! But is there anyway to use OSD instead of traytip for the song information?


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 38 posts ]  Go to page 1, 2, 3  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Klark92, Newl, patgenn123, poserpro, Yahoo [Bot] and 14 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group