Answers:
如果授予了允许UI脚本编写的必要可访问权限,则此脚本将通过“ 系统首选项”以编程方式调整屏幕亮度:
tell application "System Preferences"
set current pane to pane id "com.apple.preference.displays"
reveal anchor "displaysDisplayTab" of current pane
end tell
tell application "System Events" to tell ¬
process "System Preferences" to tell ¬
window 1 to tell ¬
tab groups to tell ¬
groups to tell ¬
sliders to set its value to 0.5 -- 0.0 to 1.0
quit application "System Preferences"
您可以将您看到的值设置为0.0
(最小亮度,显示关闭)和1.0
(最大亮度)之间的任何十进制值。
如果我可能建议另一种选择,我会提供brightness
从https://github.com/nriley/brightness或安装的命令brew install brightness
。
然后,您可以轻松切换到0(暗)和1(全功率)之间的任何亮度级别,brightness .5
并且½-full。
brightness
如果这是AppleScript解决方案,您可以从AppleScript 调用。