2 votos

Activar HDR en macOS ventura usando un script de apple.

Tengo un macbook M1 Max 2021, 1tb, 64gb ram, con mac os 13.1 ventura y mi HDR siempre se apaga aleatoriamente cuando mi ordenador se despierta del reposo. Mis monitores son dell s3422dwg y dell s2721dgf.

Mis externos son el 1 y el 3 mientras que mi interno es el monitor 2.

Tengo que ir al menú y buscar los monitores y activar el control deslizante hdr.

Estoy intentando escribir un script de apple que pueda habilitar HDR en los monitores externos sin afectar a mi monitor retina interno. La pantalla interna sólo puede activar o desactivar tru tones no hdr.

Esto es lo que tengo hasta ahora, pero me sigo encontrando con un error de fin de línea.

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

Luego también intenté hacerlo de otra manera como esta,

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

Pero la aplicación de preferencias del sistema se abre en la pestaña de apariencia y me arroja un error error "System Settings got an error: AppleEvent handler failed." number -10000 .

Acabo de empezar a usar apple script y no estoy muy seguro de lo que estoy haciendo. Cualquier ayuda sería muy apreciada. Gracias.

1voto

geocoin Puntos 121

Robado de aquí: https://gist.github.com/skempken/46c184c1a5eac2e88c9c31ce09a38300

use AppleScript version "2.4" -- Yosemite (10.10) or later
use framework "Foundation"
use framework "AppKit"
use scripting additions

tell application "System Settings"
    activate
    current application's NSWorkspace's sharedWorkspace()'s openURL:(current application's NSURL's URLWithString:"x-apple.systempreferences:com.apple.Displays-Settings.extension")
    delay 0.5

    tell application "System Events"
        tell process "System Settings"
            key code 48 -- One tab to hit left monitor
            delay 0.5

            -- activate hdr on left monitor                         
            set hdr to checkbox 1 of group 3 of scroll area 2 of group 1 of group 2 of splitter group 1 of group 1 of window "Displays" of application process "System Settings" of application "System Events"
            tell hdr
                if value is 0 then click it
             end tell

            key code 48 -- Switch to the MBP screen         
            key code 48 -- Another tab to hit the right monitor
            delay 0.5
            -- do it again
            set hdr to checkbox 1 of group 3 of scroll area 2 of group 1 of group 2 of splitter group 1 of group 1 of window "Displays" of application process "System Settings" of application "System Events"
            tell hdr
                if value is 0 then click it
            end tell

        end tell
    end tell
    quit
end tell

AppleAyuda.com

AppleAyuda es una comunidad de usuarios de los productos de Apple en la que puedes resolver tus problemas y dudas.
Puedes consultar las preguntas de otros usuarios, hacer tus propias preguntas o resolver las de los demás.

Powered by:

X