有任何Spotify通过键盘快捷键对“星标”曲目进行了调整吗?


20

我是Spotify的高级订户,也是一个痴迷的生产力极客。

真正让我烦恼的一件事是,没有键盘快捷键可以为曲目添加“星标”(即,将曲目添加到收藏夹中)。我想在工作时让Spotify收音机保持打开状态,我时不时地不得不跳过去,右键单击该曲目,然后在听到我真正喜欢的歌曲时选择“ Star”。

是否有任何Spotify调整/插件可以让我使用键盘快捷方式“加注星标”曲目?


您是否正在使用Windows Media Player?
Diogo

不,只是Spotify
艾迪(Eddy)

Answers:


3

当然,请使用AutoHotkey

安装后,将其放入AutoHotkey.ahk文件:

#*::
WinWait, Spotify, 
IfWinNotActive, Spotify, , WinActivate, Spotify, 
WinWaitActive, Spotify, 
MouseClick, left,  79,  90
Sleep, 100
MouseClick, left,  256,  152
Sleep, 100
return

这将添加一个Win + Asterisk热键,它将为正在播放的曲目加注星标。

您可能也对AutoHotkey的其他Spotify快捷方式感兴趣。


1
问题是单击UNSTAR曲目时,spotify也具有相同的位置。因此请务必小心,以防您使用ahk方法
ms)

2

我尝试了另一个Autohotkey快捷方式,但该快捷方式对我不起作用(只是切换为Spotify并单击了两个盲点)。我设计了以下内容,只要您选择了“现在播放大作品”,它就会起作用:

CoordMode, Mouse, Relative
;star currently playing
+^l::
SpotifyWinHeight = 1050 ;set to 1080 - 30 for small taskbar size, just in case WinGetPos doesn't work for some reason
WinGetActiveTitle, CurWindow
WinActivate Spotify
WinWaitActive Spotify
WinGetPos,  ,  ,  , SpotifyWinHeight, Spotify
;          X  Y  W  H, we don't care about anything but height
RightClickTarget := SpotifyWinHeight - 250
ContextMenuTarget := RightClickTarget + 110
MouseMove, 100, %RightClickTarget%
Click Right
Sleep, 50
MouseMove, 180, %ContextMenuTarget%
Sleep, 50
Click
WinActivate %CurWindow%
return

它执行以下操作:

  • 存储当前活动的窗口
  • 激活Spotify
  • 计算单击专辑插图相对于Spotify窗口的偏移量
  • 为当前正在播放的内容加注星标(通过右键单击图稿,左键单击加星标)
  • 恢复所有在此之前处于活动状态的窗口

它不是完美的(如果由于某种原因,您发现发现大部分屏幕悬挂在右侧,可能会不满意),但是在大多数情况下都能完成工作。


这很棒!谢谢。一种改进是读取最后一个上下文菜单项,以查看其是否显示“取消星标”,如果不是,请不要单击它。如果可以的话,我会回去发布。
GollyJer 2012年

2

加星标已不再是一回事。

转到此处以获取更新的问答。


下面的旧答案...

这是另一个AutoHotkey解决方案。有自由派的评论。此外,如果需要,AutoHotkey文档和论坛也是学习的好地方。

按Control + Shift + *将为活动歌曲加注星标。
该脚本的主要功能是检查歌曲是否已加星标,如果已加星标则将其保留。

^+*::
spotify = ahk_class SpotifyMainWindow
IfWinExist, %spotify%
{
;Store active window and mouse position.
WinGetActiveTitle, activeWindow
MouseGetPos x, y, winID

;Activate Spotify.
WinActivate %spotify%
WinWaitActive %spotify%

;Right click near the song title in the "Now Playing" box.
WinGetPos,  ,  ,  , spotifyHeight, %spotify%
MouseClick, Right, 100, spotifyHeight - 70, 1, 0

;Get the contents of the context menu.
WinWait, ahk_class #32768
SendMessage, 0x1E1      ; MN_GETHMENU
allContextMenuInfo := ErrorLevel

;The "Star" command is the 5th menu item.
;If the song is Unstarred the text is Star, and vice versa. But sometimes some wierd characters are included.
;The only reliable way I found is to check if the first letter is S.
menuText_StarUnstar := GetContextMenuItemText(allContextMenuInfo, 5)
StringGetPos, positionOfS, menuText_StarUnstar, S

;If S is the first letter, star the song.
notStarred := (%positionOfS% = 0)
If notStarred {
    ;Arrow down to the Star menu item and press enter.
    Send {Down}{Down}{Down}{Down}{Down}{Enter}
} Else {
    ;Just close the context menu.
    Send {Escape}
}

;Restore original window and mouse position.
WinActivate ahk_id %winID%
MouseMove %x%, %y%
}

Return

;Conext menu helper function.
GetContextMenuItemText(hMenu, nPos)
{
length := DllCall("GetMenuString"
        , "UInt", hMenu
        , "UInt", nPos
        , "UInt", 0 ; NULL
        , "Int", 0  ; Get length
        , "UInt", 0x0400)   ; MF_BYPOSITION
    VarSetCapacity(lpString, length + 1)
    length := DllCall("GetMenuString"
        , "UInt", hMenu
        , "UInt", nPos
        , "Str", lpString
        , "Int", length + 1
        , "UInt", 0x0400)
return lpString
}

这不再起作用。请参阅我的解决方案。
tig 2015年

0

我没有代表在GollyJer的答案中添加注释,但我注意到在尝试使用该脚本时,{down}击键存在问题,这会使其以某种方式将播放列表中的突出显示的歌曲下移,而不是在菜单上向下移动。我对其进行了修改,以便在“星”菜单项上单击鼠标而不是使用键,这似乎工作得很好。我还对其进行了编辑,以在将Spotify最小化之前将其最小化,然后再翻转回您使用的窗口。

^+*::
spotify = ahk_class SpotifyMainWindow
IfWinExist, %spotify%
{
WinGet, MMX, MinMax, %spotify%
;Store active window and mouse position.
WinGetActiveTitle, activeWindow
MouseGetPos x, y, winID

;Activate Spotify.
WinActivate %spotify%
WinWaitActive %spotify%

;Right click near the song title in the "Now Playing" box.
WinGetPos,  ,  ,  , spotifyHeight, %spotify%
MouseClick, Right, 100, spotifyHeight - 70, 1, 0

;Get the contents of the context menu.
WinWait, ahk_class #32768
SendMessage, 0x1E1      ; MN_GETHMENU
allContextMenuInfo := ErrorLevel

;The "Star" command is the 5th menu item.
;If the song is Unstarred the text is Star, and vice versa. But sometimes some wierd characters are included.
;The only reliable way I found is to check if the first letter is S.
menuText_StarUnstar := GetContextMenuItemText(allContextMenuInfo, 5)
StringGetPos, positionOfS, menuText_StarUnstar, S

;If S is the first letter, star the song.
notStarred := (%positionOfS% = 0)
If notStarred {
    ;Arrow down to the Star menu item and press enter.
    MouseClick, Left, 20, -120, 1, 0,, R
} Else {
    ;Just close the context menu.
    Send {Escape}
}

;Restore original window and mouse position.
IfEqual MMX, -1, WinMinimize, %spotify%
WinActivate ahk_id %winID%
MouseMove %x%, %y%
}

Return

;Context menu helper function.
GetContextMenuItemText(hMenu, nPos)
{
length := DllCall("GetMenuString"
        , "UInt", hMenu
        , "UInt", nPos
        , "UInt", 0 ; NULL
        , "Int", 0  ; Get length
        , "UInt", 0x0400)   ; MF_BYPOSITION
    VarSetCapacity(lpString, length + 1)
    length := DllCall("GetMenuString"
        , "UInt", hMenu
        , "UInt", nPos
        , "Str", lpString
        , "Int", length + 1
        , "UInt", 0x0400)
return lpString
}


0

依赖于“星号”命令的解决方案不再起作用...不再有星号命令,但是“星号”是可以添加文件夹的项目。该脚本执行此操作。

; Spotify "Star Song"
^+*::
spotify = ahk_class SpotifyMainWindow
IfWinExist, %spotify%
{
;Store active window and mouse position.
WinGetActiveTitle, activeWindow
MouseGetPos x, y, winID

;Activate Spotify.
WinActivate %spotify%
WinWaitActive %spotify%

;Right click near the song title in the "Now Playing" box.
WinGetPos,  ,  ,  , spotifyHeight, %spotify%
MouseClick, Right, 100, spotifyHeight - 70, 1, 0

;Open Add To... sub-menu
Send {A}

;The "Starred" command is the 2nd menu item. If the song is Starred it will be disabled.
Send {Down}{Enter}

;Restore original window and mouse position.
WinActivate ahk_id %winID%
MouseMove %x%, %y%
}

Return

0

Spotify不再具有“星号”,而且我似乎也无法再检索上下文菜单的内容,因此此方法将查看上下文菜单中的像素颜色并使用箭头键进行选择。如果最大化,最小化以及专辑封面大小,则适用。

^+*::
{
    spotify = ahk_class SpotifyMainWindow
    IfWinExist, %spotify% 
    {
        ;Store active window and mouse position.
        WinGet, MMX, MinMax, %spotify%
        WinGetActiveTitle, activeWindow
        MouseGetPos x, y, winID

        ;Activate Spotify.
        WinActivate %spotify%
        WinWaitActive %spotify%

        ;Get maximised status
        WinGet, isMaximised, MinMax

        ;Clear any context menus
        Send {Escape down}{Escape up}

        ;Right click near the song title in the "Now Playing" box.
        WinGetPos,  ,  ,  , spotifyHeight, %spotify%
        MouseClick, Right, 44, spotifyHeight - (isMaximised = 1 ? 75 : 66), 1, 0
        sleep 200
        MouseMove 10,0, ,R
        sleep 200

        ; Determine if the song is already added to your library or not
        ; Look at left edge of the 'S' in Save to Your Library
        ; or the 'R' in Remove from Your Library
        ; 0x282828 is the background color of the menu
        ; if the background color is not present then the song is not in your library
        PixelGetColor, pixelColor, 91, spotifyHeight - (isMaximised = 1 ? 129 : 119)
        if (pixelColor = 0x282828) {
            ;Move up to 'Save to Your Library' and hit enter
            loop, 1 {
                Send {Up down}
                sleep 50
                Send {Up up}
                sleep 50
            }
            Send {Enter down}
            sleep 50
            Send {Enter up}
            sleep 50
        } else {
            ; Already added, so close context menu
            Send {Escape down}
            sleep 50
            Send {Escape up}
            Sleep 50
        }

        ;Restore original window and mouse position.
        IfEqual MMX, -1, WinMinimize, %spotify%
        WinActivate ahk_id %winID%
        MouseMove %x%, %y%

    }
    Return
}
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.