applescript – Enabling HDR on macOS ventura using an apple script

Spread the love


I have a macbook M1 Max 2021, 1tb, 64gb ram, with mac os 13.1 ventura and my HDR always randomly turns off when my computer wakes up from sleep. My monitors are dell s3422dwg and dell s2721dgf.

My externals are 1 and 3 while my internal is monitor 2.

I have to go into the menu and find the monitors and enable the hdr slider.

I am trying to write an apple script that can enable HDR on the external monitors without affecting my internal retina monitor. The internal screen can only enable or disable tru tones not hdr.

Here is what I have so far but I keep running into an end of line error.

tell application "System Preferences"
    activate
    reveal anchor "displaysDisplayTab" of pane id "com.apple.preference.displays"
    tell anchor "displaysDisplayTab" of pane id "com.apple.preference.displays"
        tell table 1 of scroll area 1
            select (row whose value of static text 1 contains "DELL S3422DWG")
        end tell
        tell table 1 of scroll area 1
            select (row whose value of static text 1 contains "DELL S2721DGF")
        end tell
        click checkbox "High Dynamic Range" of group 1
    end tell
    quit
end tell

Then I also tried to do it another way like this,

tell application "System Settings"
    activate
    set current pane to pane id "com.apple.preference.displays"
end tell


tell application "System Events"
    tell process "System Preferences"
        set frontmost to true
        repeat until exists window "Displays"
        end repeat
        tell scroll area 1 of group 1 of window "Displays"
            click checkbox "High Dynamic Range"
        end tell
    end tell
end tell

tell application "System Settings"
    quit
end tell

But the system preferences app opens up on the appearance tab and I get thrown an error error "System Settings got an error: AppleEvent handler failed." number -10000.

I just started using apple script and I am not really sure what I am doing. Any help would be greatly appreciated. Thanks!


Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *