3 replies
Sign in or join Beachball Help to reply.
- 0
Community User ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
I've checked with the Automator actions and haven't found anything either. I also opened Script Editor and perused the System Events dictionary and the System Preferences dictionary to no avail.
Seems like someone wrote an Automator action for adjusting the brightness some while ago, but I'm not sure. You might want to check the Automator actions on Apple's download page. An easy shortcut is from the Apple menu in the menu bar in the upper left corner of the screen, then select "Mac OS X Software...". You might also Google for it.
- 0
orangekay ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
I'm not sure there's even a C API for this, so I wouldn't expect to see an AppleScript wrapper for it.
- 0
Community User ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
Well then, I guess we go with scripting the GUI. You'll need to have your computer enabled for assistive devices, which you do in System Preferences > Universal near the bottom of the window. Otherwise, the script won't work and the computer will give you an error telling you need to do this. Enabling for assistive devices needs an admin name and password, but you only have to set it once.
Here's an AppleScript that'll set the brightness. I used a few bits from one of the scripts Apple provided, named "Set Output Volume" found in the computer scripts folder. (Check the Scripts menu in the menu bar, which is available through the AppleScript Utility app.)
tell application "System Events"
tell application "System Preferences" to reveal the anchor "displaysDisplayTab" of pane named "Displays"
delay 0.5
set visible of process "System Preferences" to false
tell slider 1 of group 2 of tab group 1 of window 1 of process "System Preferences"
if value is 0.5 then
set value to 1.0
else
set value to 0.5
end if
end tell
end tellProbably deserves a bit of explanation. The first part makes sure System Preferences is open and has the Displays preferences shown, with the Display tab selected (not the Color). In order to hide System Preferences, it must be done switching to the Displays pane and selecting the Display tab. I've inserted a half second delay to allow for this, hopefully. Leaving System Preferences open and hidden will keep you from having to see the System Preferences window every time you run the script, as long as the correct pane is already selected.
The second part goes on to tell System Events to go through the UI elements to set the value of the slider controlling the brightness, any value from 0.0 to 1.0. There's a little bit of extra code with "if... else" in case you wanted to use it to toggle between different brightness settings.
If you like, you can create an Automator workflow and insert this into a "Run AppleScript" action.