 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
zzzztag Guest
|
Posted: Mon Dec 08, 2008 4:12 pm Post subject: Spotify and AHK |
|
|
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! |
|
| Back to top |
|
 |
Frankie
Joined: 02 Nov 2008 Posts: 823
|
Posted: Mon Dec 08, 2008 4:27 pm Post subject: |
|
|
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. _________________ Click here to join #AHK channel in IRC for general chat and quick help. |
|
| Back to top |
|
 |
zzzztag Guest
|
Posted: Mon Dec 08, 2008 6:06 pm Post subject: |
|
|
ty!
got the most important hotkeys going now! |
|
| Back to top |
|
 |
zzzzTAG Guest
|
Posted: Tue Dec 09, 2008 12:23 am Post subject: |
|
|
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? |
|
| Back to top |
|
 |
Frankie
Joined: 02 Nov 2008 Posts: 823
|
Posted: Tue Dec 09, 2008 12:29 am Post subject: |
|
|
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
|
_________________ Click here to join #AHK channel in IRC for general chat and quick help. |
|
| Back to top |
|
 |
zzzztag Guest
|
Posted: Tue Dec 09, 2008 12:37 am Post subject: |
|
|
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. |
|
| Back to top |
|
 |
zzzztag Guest
|
Posted: Tue Dec 09, 2008 12:55 am Post subject: |
|
|
| 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. |
|
| Back to top |
|
 |
glok777
Joined: 09 Dec 2008 Posts: 3
|
Posted: Tue Dec 09, 2008 1:12 am Post subject: |
|
|
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
}
|
|
|
| Back to top |
|
 |
zzzztag Guest
|
Posted: Tue Dec 09, 2008 1:40 am Post subject: |
|
|
| Are you sure it updates the GUI if you switch songs? |
|
| Back to top |
|
 |
glok777
Joined: 09 Dec 2008 Posts: 3
|
Posted: Tue Dec 09, 2008 1:56 am Post subject: |
|
|
| No I see that that doesn't work ... |
|
| Back to top |
|
 |
glok777
Joined: 09 Dec 2008 Posts: 3
|
Posted: Tue Dec 09, 2008 2:03 am Post subject: |
|
|
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
|
|
|
| Back to top |
|
 |
zzzztag Guest
|
Posted: Tue Dec 09, 2008 2:19 am Post subject: |
|
|
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 |
|
|
| Back to top |
|
 |
zzzTAG
Joined: 22 Jun 2006 Posts: 6
|
Posted: Tue Dec 09, 2008 2:27 am Post subject: |
|
|
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 |
|
|
| Back to top |
|
 |
zzzTAG
Joined: 22 Jun 2006 Posts: 6
|
Posted: Tue Dec 09, 2008 2:39 am Post subject: |
|
|
ok, happy with this for now
| 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 |
|
|
| Back to top |
|
 |
Zawaq
Joined: 03 Jan 2009 Posts: 4
|
Posted: Sun Jan 04, 2009 4:33 am Post subject: |
|
|
| Thanks for the script! But is there anyway to use OSD instead of traytip for the song information? |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|