0 votos

applescript: comandos para maximizar (botón verde) una ventana de iTerm

Asumiendo que estoy abriendo una ventana de iTerm con el siguiente AppleScript:

tell application "iTerm"
            set win1 to (create window with default profile)
        repeat until exists win1
            delay 0.01
        end repeat
        tell current session of current tab of current window
            write text "watch -n1 " & "'"  & "kubectl get pods | grep -i " & input & "'"
            split horizontally with default profile
            split vertically with default profile
        end tell

¿Qué fragmento de código debo utilizar para que win1 se maximiza (como al hacer clic en el botón verde de la ventana)?

editar En cuanto a la propuesta de solución indicada en la pregunta que se supone duplicada, he modificado mi fragmento de la siguiente manera:

    tell application "iTerm"
            set win1 to (create window with default profile)
        repeat until exists win1
            delay 0.01
        end repeat
        tell application "System Events"
            perform action "AXZoomWindow" of (first button whose subrole is "AXFullScreenButton") of (first window whose subrole is "AXStandardWindow") of (first process whose frontmost is true)
        end tell
        tell current session of current tab of current window
            write text "watch -n1 " & "'"  & "kubectl get pods | grep -i " & input & "'"
            split horizontally with default profile
            split vertically with default profile
        end tell

Sin embargo, esto abre una nueva ventana de terminal y no se ejecuta ningún otro comando.

1voto

user3439894 Puntos 5883

El perform action comando va a ir el frontales que cumple con los criterios de la ventana dada comando . Por lo tanto, es necesario utilizar el activate comando después de tell application "iTerm" así que win1 será frontales cuando el perform action comando se activa.

tell application "iTerm"
        activate
        set win1 to (create window with default profile)
    repeat until exists win1
        delay 0.01
    end repeat
    tell application "System Events"
        perform action "AXZoomWindow" of (first button whose subrole is "AXFullScreenButton") of (first window whose subrole is "AXStandardWindow") of (first process whose frontmost is true)
    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