Post

Replies

Boosts

Views

Activity

Reply to applescript script stopped working after 12.0.1 (Monterey) upgrade
On macOS Monterey, I'm using the following script to set my MacBook Pro's built-in display brightness (in a multiple display set-up). set myBrightness to 0.71 -- # Start with System Preferences closed if running of application "System Preferences" then try tell application "System Preferences" to quit on error do shell script "killall 'System Preferences'" end try end if repeat while running of application "System Preferences" is true delay 0.2 end repeat -- # Open System Preferences to the target pane tell application "System Preferences" reveal anchor "displaysDisplayTab" of pane id "com.apple.preference.displays" activate repeat while name of window 1 is not "Displays" delay 0.2 end repeat end tell -- # Change the Brightness tell application "System Events" try tell process "System Preferences" -- Open the Display Settings sheet click button "Display Settings…" of window 1 repeat until sheet 1 of window 1 exists delay 0.2 end repeat -- Select the built-in display select row 1 of outline 1 of scroll area 1 of sheet 1 of window "Displays" repeat until slider 1 of sheet 1 of window 1 exists delay 0.2 end repeat -- Set the built-in display brightness set value of slider 1 of sheet 1 of window 1 to myBrightness repeat until value of slider 1 of sheet 1 of window 1 > (myBrightness - 0.05) and value of slider 1 of sheet 1 of window 1 < (myBrightness + 0.05) delay 0.2 end repeat -- Close the Display Settings sheet click button "Done" of sheet 1 of window 1 repeat while sheet 1 of window 1 exists delay 0.2 end repeat end tell end try end tell -- # Close System Preferences quit application "System Preferences"
Oct ’22