Cocoa 编程更改macOS Mojave强调色
我正在编写一个应用程序,允许用户设置macOS Mojave的重音颜色 我的第一次尝试是使用AppleScript。但我意识到API还不是最新的: 带下划线的API可以工作,但它只有2个颜色选项,而新操作系统有8个Cocoa 编程更改macOS Mojave强调色,cocoa,applescript,macos-mojave,Cocoa,Applescript,Macos Mojave,我正在编写一个应用程序,允许用户设置macOS Mojave的重音颜色 我的第一次尝试是使用AppleScript。但我意识到API还不是最新的: 带下划线的API可以工作,但它只有2个颜色选项,而新操作系统有8个 我想知道是否有解决办法。语言是不受限制的,只要它有效。谢谢。这是一个完整的AppleScript解决方案,允许用户选择明暗模式、高亮颜色和强调颜色。如果用户在突出显示颜色选项中选择“其他”,脚本可能会抛出错误,因为我没有为该选项定义任何操作(计算该部分可能是您自己学习和计算的一个好
我想知道是否有解决办法。语言是不受限制的,只要它有效。谢谢。这是一个完整的AppleScript解决方案,允许用户选择明暗模式、高亮颜色和强调颜色。如果用户在突出显示颜色选项中选择“其他”,脚本可能会抛出错误,因为我没有为该选项定义任何操作(计算该部分可能是您自己学习和计算的一个好过程)
这对我不起作用。在三个选项之后,它将无限期运行。不确定其中哪些部分(如果有的话)依赖于区域设置。
property appearanceMode : {"Light", "Dark"}
property accentColors : {"Blue", "Purple", "Pink", "Red", "Orange", "Yellow", "Green", "Graphite"}
property highlightColors : {"Blue", "Purple", "Pink", "Red", "Orange", "Yellow", "Green", "Graphite", "Other"}
set chosenAppearanceMode to (choose from list appearanceMode ¬
with title "Please Choose Your Accent Color" with prompt ¬
"Please Choose Your Accent Color" OK button name ¬
"OK" cancel button name "CANCEL") as string
set chosenAccentColor to (choose from list accentColors ¬
with title ¬
"Please Choose Your Accent Color" with prompt ¬
"Please Choose Your Accent Color" OK button name ¬
"OK" cancel button name "CANCEL") as string
set chosenHighlightColor to (choose from list highlightColors ¬
with title ¬
"Please Choose Your Highlight Color" with prompt ¬
"Please Choose Your Highlight Color" OK button name ¬
"OK" cancel button name "CANCEL") as string
tell application "System Preferences"
reveal anchor "Main" of pane id "com.apple.preference.general"
end tell
tell application "System Events"
repeat until exists of checkbox chosenAppearanceMode of window "General" of application process "System Preferences"
delay 0.1
end repeat
-- Appearance
click checkbox chosenAppearanceMode of window "General" of application process "System Preferences"
-- Accent Color
click checkbox chosenAccentColor of window "General" of application process "System Preferences"
-- Dropdown Menu For Highlight Color
click pop up button 1 of window "General" of application process "System Preferences"
-- Highlight Color
click menu item chosenHighlightColor of menu 1 of pop up button 1 of window "General" of application process "System Preferences"
end tell
tell application "System Preferences" to quit