Date
1 - 1 of 1
Activate Terminal and put it in Fullscreen mode
Jean-Christophe Helary <jean.christophe.helary@...>
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