1 votos

Ocultar/Mostrar el icono de la batería en la barra de menús con AppleScript

¿Existe algún método para mostrar el elemento de estado de la barra de menú de la batería con AppleScript? He intentado buscar en la librería script pero no he encontrado ninguno que se ajuste a esta capacidad.

Simplemente quiero alternar el estado del elemento de la barra de menú que se encuentra en Preferencias del Sistema " Ahorro de energía " Adaptador de corriente el escenario. No es necesario crear una aplicación AppleScript para ello.

OS X Yosemite » Energy Saver » Power Adapter

2voto

Tim Brigham Puntos 8727

Actualización: Este script actualizado no parpadea por la pantalla, es decir, se ejecuta en el backgound. La versión antigua sigue siendo válida.

tell application "System Events"
    tell process "System Preferences"
        activate
    end tell
    tell application "System Preferences"
        set current pane to pane "com.apple.preference.energysaver"
    end tell
    tell process "System Preferences"
        click checkbox 1 of window 1
    end tell
    tell application "System Preferences"
        quit
    end tell
end tell

Desde el 18 de octubre:

-- Allow Script Editor in Accessibility <- Privacy <- Security & Privacy <-  System Preferences. For testing, at the very least.

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

tell application "System Events"
    tell process "System Preferences"
        tell window 1
            click checkbox 1
        end tell
    end tell
end tell

tell application "System Preferences"
    quit
end tell

-- Create an Automator Service with this, so that you can bind the action to a keyboard shortcut.

1voto

Tim Brigham Puntos 8727

La pregunta es imprecisa. ¿Te refieres a un applescript para mostrar el menú desplegable desde el icono de la batería en la parte derecha de la barra de menú?

tell application "System Events" to tell process "SystemUIServer"
    click (first menu bar item whose value of attribute "AXDescription" contains "Battery") of menu bar 1
end tell

1voto

Tim Brigham Puntos 8727
tell application "System Preferences"
    activate
    set current pane to pane "com.apple.preference.energysaver"
end tell

tell application "System Events" to set bool to value of attribute "AXValue" of checkbox 1 of window 1 of process "System Preferences"

tell application "System Preferences"
    quit
end tell

if bool is 1 then
    display notification "Battery icon is visible" with title "Put a title here" subtitle "Subtitle here"
else
    display notification "Battery icon is hidden" with title "Put a title here" subtitle "Subtitle here"
end if

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