0 votos

Cómo utilizar Applescript para ajustar el volumen del sonido de salida

Quiero modificar el Applescript que utilizo para seleccionar la salida de sonido, para que también marque el volumen de salida al 100%.

(*
Applescript to toggle between two sound outputs by Line number, ¬
as they appear in the Sound Control Panel. Based on code by ¬
Arthur Hammer http://apple.stackexchange.com/a/209434/85275
*)

set internal to 1 --internal speakers
set batcave to 3 --Bat Cave

tell application "System Preferences"
    activate
    set current pane to pane "com.apple.preference.sound"
end tell

tell application "System Events"
    tell application process "System Preferences"
        repeat until exists tab group 1 of window "Sound"
        end repeat

        -- I added this line to dial the volume up to 100%
        set volume output volume 1.0

        tell tab group 1 of window "Sound"
            click radio button "Output"
            if (selected of row internal of table 1 of scroll area 1) then
                set selected of row batcave of table 1 of scroll area 1 to true
            else
                set selected of row internal of table 1 of scroll area 1 to true
            end if
        end tell
    end tell
end tell
--tell application "System Preferences" to quit
--remove the comment '--' tag above to make the control panel quit afterwards, leave for testing.

El error es:

tell current application
    set volume «class pcap» "System Preferences" output volume 1.0
Result:
error "System Events got an error: Can’t make application process \"System Preferences\" into type small real." number -1700 from application process "System Preferences" to small real

Supongo que me faltan algunos comandos contextualizadores como "tell..." delante del comando "set column". ¿Sugerencias?

Estoy ejecutando MacOS 10.15.7 (Catalina)

1voto

wch1zpink Puntos 11

En set volume output volume es un comando Ampliaciones estándar pero lo está utilizando dentro de un comando Eventos del sistema tell block . Si quieres mantener esa línea de código justo donde está en tu ejemplo, cámbiala por esto...

my (set volume output volume 100) -- if 1.0 fails, try 100

O prueba esto...

set internal to 1 --internal speakers
set batcave to 3 --Bat Cave

set volume output volume 100

tell application "System Preferences"
    activate
    set current pane to pane "com.apple.preference.sound"
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