【发布时间】:2023-02-07 04:43:06
【问题描述】:
我只能在谷歌上找到一些带有特定音乐应用程序(如 itunes、spotify 等)的 applescripts 来获取当前播放的歌曲。
但是现在我用的是不支持applescript控制的网易音乐,请问有没有什么通用的方法可以通过mac media center获取当前播放的歌曲信息?
Applescript 和其他命令行工具都可以。
【问题讨论】:
标签: macos applescript
我只能在谷歌上找到一些带有特定音乐应用程序(如 itunes、spotify 等)的 applescripts 来获取当前播放的歌曲。
但是现在我用的是不支持applescript控制的网易音乐,请问有没有什么通用的方法可以通过mac media center获取当前播放的歌曲信息?
Applescript 和其他命令行工具都可以。
【问题讨论】:
标签: macos applescript
这以下AppleScript代码使用 UI 脚本来检索当前播放的媒体。
tell application "System Events" to tell process "Control Center"
click menu bar item "Control Center" of menu bar 1
set currentlyPlaying to value of static text 3 of window "Control Center"
key code 53 -- press 'esc' key
end tell
activate
display dialog currentlyPlaying with title "Currently Playing" buttons ¬
{"OK"} default button 1 giving up after 3
【讨论】:
我制作了一个适用于 macOS Ventura 的工具:
【讨论】: