OSX 勾选菜单栏复选框
OSX tick menu bar checkbox
对于我的应用程序MuteSpotifyAds,我不想添加自动启用私人会话模式的功能。
为此,我不想在 OSX 菜单栏的 Spotify
菜单中切换菜单栏项目 Private Session
。我使用以下有效的 applescript:
来源:
tell application "System Events" to tell process "Spotify"
tell menu bar item 2 of menu bar 0
click
click menu item "Private Session" of menu 1
end tell
end tell
问题是我必须检查复选框是否已经被选中,否则我会禁用 Private Session
。
有没有办法检查菜单复选框是否已经被勾选?
我已经尝试过 this,但似乎只适用于实际 windows 中的复选框。
如果您有不使用 applescript 的解决方案,那也很好!
菜单项是否勾选的信息在菜单项的属性"AXMenuItemMarkChar"中
tell application "System Events" to tell process "Spotify"
tell menu bar item 2 of menu bar 1 -- AppleScript indexes are 1-based
tell menu item "Private Session" of menu 1
set isChecked to value of attribute "AXMenuItemMarkChar" is "✓"
if not isChecked then click it
end tell
end tell
end tell
对于我的应用程序MuteSpotifyAds,我不想添加自动启用私人会话模式的功能。
为此,我不想在 OSX 菜单栏的 Spotify
菜单中切换菜单栏项目 Private Session
。我使用以下有效的 applescript:
来源:
tell application "System Events" to tell process "Spotify"
tell menu bar item 2 of menu bar 0
click
click menu item "Private Session" of menu 1
end tell
end tell
问题是我必须检查复选框是否已经被选中,否则我会禁用 Private Session
。
有没有办法检查菜单复选框是否已经被勾选?
我已经尝试过 this,但似乎只适用于实际 windows 中的复选框。
如果您有不使用 applescript 的解决方案,那也很好!
菜单项是否勾选的信息在菜单项的属性"AXMenuItemMarkChar"中
tell application "System Events" to tell process "Spotify"
tell menu bar item 2 of menu bar 1 -- AppleScript indexes are 1-based
tell menu item "Private Session" of menu 1
set isChecked to value of attribute "AXMenuItemMarkChar" is "✓"
if not isChecked then click it
end tell
end tell
end tell