是否有任何方法可以模拟从 Spotify 外部单击 macOS Spotify 应用程序中的 Spotify DJ 按钮,例如通过按键?
当然,我可以打开 Spotify 窗口并单击它。但我经常使用 Hammerspoon 来自动执行许多其他任务,例如窗口操作,因此如果能够按下全局键绑定(例如,Shift+⏩)让 DJ 知道要移动到哪个位置,那就太好了下一组,不会进一步打断我正在做的事情。
我研究过的一些想法:
Spotify 的 AppleScript API:我没有找到点击 DJ 按钮的方法。 (您可以使用
Script Editor
应用程序、文件 -> 打开词典、Spotify 查看)。
检查菜单栏中的某些内容,我可以使用 hs.application:selectMenuItem() 单击,但我找不到相关的菜单栏项目
其他一些资源,比如 CLI 工具、Node.js 程序等,我找到的只是 AppleScript 的包装器
右键单击 Dock 图标;下一个/上一个,但没有 DJ 按钮选项
libspotify:已停止使用,怀疑它是否支持最近的 DJ 功能
Spotify 的 Web Playback SDK 参考 和 Spotify 的 Web API:需要编写应用程序、使用 Oauth 等 - 我愿意,而且我能够获取有关 DJ 的播放列表信息,但我没有查看任何具有 DJ 按钮功能的东西
一个不太好的主意可能就是简单地跳过 5 首曲目
谢谢。
brew install cliclick
#!/usr/bin/osascript
# go to mission control screen 1 where Spotify is always in the same place
tell application "System Events"
key code 1 using control down
end tell
tell application "Spotify"
activate
end tell
delay 1
# get coordinates from shift-ctrl-4
do shell script "/opt/homebrew/bin/cliclick c:380,492"