AppleScript: Set Display Brightness
After a few less useful hits, I finally came to an old blog post called “Change Monitor Brightness Using AppleScript.” It was exactly what I needed, with three exceptions:
- Since it’s four years old, it hasn’t been updated for Mountain Lion.
- It isn’t designed to change multiple displays concurrently.
- It doesn’t include the ability to specify the brightness level, on the fly.
Having solved all three of these problems, I post my results, in hopes that it may help someone else:
set brightness_level to (text returned of (display dialog "Set Brightness Level" default answer ".875" buttons {"Cancel", "OK"} default button "OK")) as numbertell application "System Preferences"activateset current pane to pane "com.apple.preference.displays"tell application "System Events"set j to (count windows of process "System Preferences")repeat with i from 1 to jset value of slider 1 of group 1 of tab group 1 of window i of process "System Preferences" to brightness_levelend repeatend tellquitend tell
Enjoy! :-)
thank you, just want i needed, first google result :)
ReplyDeleteYou’re very welcome, 3DDR! :-)
ReplyDelete