applescript: commands to maximize (green button) an iTerm window Assuming I am opening an iTerm window with the following 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 " &amp; "'"  &amp; "kubectl get pods | grep -i " &amp; input &amp; "'"
            split horizontally with default profile
            split vertically with default profile
        end tell


What code snippet should I use so that win1 gets maximized (as in clicking on the green window button)?

edit: regarding the proposed solution indicated in the question that is supposed to be duplicate, I have changed my snippet as follows:

    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 " &amp; "'"  &amp; "kubectl get pods | grep -i " &amp; input &amp; "'"
            split horizontally with default profile
            split vertically with default profile
        end tell


However this now opens a new terminal window and no further command executes.
The perform action command is going to go the the frontmost window that meets the criteria of the the given command. As such, you need to use the activate command after tell application "iTerm" so win1 will be frontmost when the perform action command is triggered.

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
...