Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I wonder if it's possible to open a program in Lion fullscreen mode via the Terminal. I want to write a short script which starts a bunch of programs in fullscreen mode, so that I only have to click once to start my working environment.

share|improve this question
    
Is this the Lion / MTN Lion Full Screen Mode, or a window "zoomed"? –  MrDaniel Aug 1 '12 at 12:58
    
the lion fullscreen –  ABLX Aug 1 '12 at 14:10
add comment

3 Answers

up vote 5 down vote accepted

Here it is:

/usr/bin/osascript -e 'tell application "Safari"' -e "activate" -e 'tell application "System Events"' -e 'keystroke "f" using {control down, command down}' -e "end tell" -e "end tell"

Here it is in a clearer form (but you can't run it this way):

/usr/bin/osascript -e "tell application \"Safari\"" 
-e "activate"
-e "tell application \"System Events\""
-e "keystroke \"f\" using {control down, command down}"
-e "end tell"
-e "end tell"

And this is it as formatted AppleScript:

tell application "Safari"
    activate
    tell application "System Events"
        keystroke "f" using {control down, command down}
    end tell
end tell

It works by first opening a Safari window if one is not currently open. Then it simulates the Control ⌃-Command ⌘-F keystroke which tells the Safari window to become full screen.

If you want to make the window the max-size it can be without becoming full screen (i.e. taking up all the space below the menu bar at the top):

tell application "Finder"
    set desktopSize to bounds of window of desktop
end tell

tell application "Safari"
    activate
    set bounds of window 1 to desktopSize
end tell

Which would become this in Terminal:

/usr/bin/osascript -e "tell application \"Finder\"" -e "set desktopSize to bounds of window of desktop" -e "end tell" -e "tell application \"Safari\"" -e "activate" -e "set bounds of window 1 to desktopSize" -e "end tell"

For Chrome, do this:

tell application "Google Chrome"
    activate
    make new window
    tell application "System Events"
        keystroke "f" using {control down, command down}
    end tell
end tell

So it would be this in Terminal:

/usr/bin/osascript -e "tell application \"Google Chrome\"" -e "activate" -e "make new window" -e "tell application \"System Events\"" -e "keystroke \"f\" using {control down, command down}" -e "end tell" -e "end tell"

Hope this helps!

share|improve this answer
    
tryed this, and it helped a bit. it opens the app, but the fullscreen won't work - jsut gives me an error sound. have to run the script twice to go to fullscreen –  ABLX Aug 1 '12 at 20:09
    
@ABLX You need to change the keystroke for whatever app you want to fullscreen - what apps are you working with? –  CajunLuke Aug 1 '12 at 20:11
    
@qegal I believe entire screen - he mentioned Lion fullscreen in the question comments. –  CajunLuke Aug 1 '12 at 20:12
    
evernote and chrome. it should be lion fullscreen –  ABLX Aug 1 '12 at 20:13
    
aww my fault. evernotes want ^ + command + f. –  ABLX Aug 1 '12 at 20:16
show 3 more comments

Here's instructions for Google Chrome. (This will open an Incognito window to full-screen.)

Go to /Applications/Google Chrome.app/Content/MacOS/. Rename the Google Chrome binary to something else (like chrome-bin) and create an executable bash script in its place (name the script Google Chrome just like the original executable file).

#!/bin/bash
open chrome-bin --new --args -incognito

osascript -e "tell application \"Google Chrome\"" -e "tell application \"System Events\"" -e "keystroke \"f\" using {control down, command down}" -e "end tell" -e "end tell"

Now, every time you launch Google Chrome it will launch full screen in Incognito mode. I use Incognito mode, but if you don't want that, just delete the -incognito flag.

share|improve this answer
1  
The OP doesn't mention anything about Google Chrome. –  CajunLuke Sep 17 '12 at 21:58
    
Also, Incognito mode won't help one whit when it comes to malicious code - it just doesn't store or allow access to cookies and other local (browser-controlled) persistence schemes. In fact, plugins (like Flash) can store and access their own cookies even in Incognito mode. –  CajunLuke Sep 17 '12 at 22:09
    
+1 for the nice hack even if Chrome was not asked for in the question –  myhd Sep 26 '12 at 10:32
add comment

This won't work with applications that don't use native full screen windows, but should work with some that don't use the standard shortcut for entering full screen. A few applications have different process names and application names.

set a to "Notes"
set bid to id of application a
tell application a
    reopen -- open a new default window if there are no windows
    activate -- make frontmost
end tell
tell application "System Events" to tell (process 1 where bundle identifier is bid)
    click (button 1 of window 1 where subrole is "AXFullScreenButton")
end tell
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.