• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Activate Terminal and put it in Fullscreen mode
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Activate Terminal and put it in Fullscreen mode


  • Subject: Activate Terminal and put it in Fullscreen mode
  • From: Jean-Christophe Helary <email@hidden>
  • Date: Tue, 17 Oct 2017 07:04:06 +0900

Here is what I came up with, after many hours of testing why I had inconsistent
behavior. It took me a long while to find the 2 issues I mention in my comments
and find workarounds.

on ActivateFullScreenTerminal()
        (* Creates a fullscreen Terminal new tabbed window in which to launch a
command
        *)
        tell application "Terminal"
                try # to see if Terminal is launched and open a new tab
                        tell application "System Events" to tell application
process "Terminal"
                                set frontmost to true
                                keystroke "t" using {command down}
                                (* for reasons unkown to me creating a tab
*after* putting the window
                                in fullscreen mode requires a "delay" of 2 or
more on my machine, but
                                creating the tab *before* is instantaneous.*)
                        end tell
                        try #to see if a window exist, check if it is in
fullscreen
                                if number of columns of first window is less
than 115 then
                                        tell application "System Events" to
tell application process "Terminal"
                                                # put it in fullscreen
                                                keystroke "f" using {command
down, control down}
                                                (* I found that if a window is
not in fullscreen and has a tab
                                                created in it and *then* is put
to full screen, the front tab size
                                                will be the size of a
fullscreen window but the other tabs will keep
                                                their pre-fullscreen size in
their properties, until they are put to
                                                the front. That creates all
sorts of problems when testing fullscreen
                                                size since some tabbed windows
are "visually" fullscreen but
                                                programatically their
properties are not updated yet.
                                                *)
                                        end tell
                                end if
                        on error # create a window and put it in fullscreen
                                tell application "System Events" to tell
application process "Terminal"
                                        keystroke "n" using {command down}
                                        keystroke "f" using {command down,
control down}
                                end tell
                        end try
                on error # launch Terminal and put the default window in
fullscreen
                        tell application "Terminal" to activate
                        tell application "System Events" to tell application
process "Terminal"
                                keystroke "f" using {command down, control down}
                        end tell
                end try
        end tell
end ActivateFullScreenTerminal
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Activate Terminal and put it in Fullscreen mode
      • From: Shane Stanley <email@hidden>
  • Prev by Date: Re: Awful bugs in HS Mail
  • Next by Date: Re: Activate Terminal and put it in Fullscreen mode
  • Previous by thread: Fullscreen Terminal weirdness
  • Next by thread: Re: Activate Terminal and put it in Fullscreen mode
  • Index(es):
    • Date
    • Thread