I use iA Writer enough that I would like it to open in fullscreen on login, but unfortunately the developers have disdain for preferences.

I decided to write an AppleScript that I could add to the startup list, but I can't get it to work properly. I'd like to open a specific file using iA Writer on login, in 10.8 fullscreen mode, but without changing focus from my normal desktop, or a least automatically returning me to my primary desktop after launch. EDIT: Here is my code after suggested edits:

set front_application to front window
tell (application "iA Writer") to open (POSIX file "/PATH/TO/FILE.txt")
activate application "iA Writer"
#EDITED# tell application "System Events" to keystroke "f" using {command down, control down}
#ADDED# delay 1
#ADDED# tell application "System Events" to keystroke "1" using control down
end tell
activate front_application

This code successfully opens the file with iA Writer in fullscreen, but switches to the new, iA Writer-controlled desktop, waits a moment, and switches back to my main desktop.

Since OS X's change from spaces to desktops, I don't even know if it is even possible to open an application in Mountain/Lion fullscreen without it stealing focus and forcing a desktop switch.

Many thanks to @Lauri Ranta for your help thus far!

Any further help, regarding keeping iA Writer from switching desktops when becoming fullscreen, would be very appreciated. Thanks!


(I removed the original script, but I couldn't come up with anything better than this either.)

set fw to front window
do shell script "open ~/Notes/todo.txt -Fa iA\\ Writer"
delay 0.1
tell application "System Events" to tell process "iA Writer"
    perform action "AXPress" of (button 1 where subrole is "AXFullScreenButton") of window 1
end tell
delay 1.5
activate fw

WriteRoom has an option to open documents in custom full screen windows. If it's selected, you could use something like open file.txt -Fjga WriteRoom.

If someone else just needs to open an application on the background, you can use open -jg or launch. launch sometimes opens a visible window if an application isn't open and open -jg if an application is open but has no windows.

set b to "com.apple.TextEdit"
tell application "System Events"
    if bundle identifier of processes contains b then
        launch application id b
        do shell script "open -jgb " & b
    end if
end tell
  • I haven't enabled restoring app windows, since iA Writer is the only one I'd like to have this behavior. I enabled changing desktops with [CONTROL] + number keys, and added a delay of 1 before sending the [CONTROL] + 1 keystroke. This gives iA Writer just enough time to enter fullscreen before switching. It's not ideal, as I was hoping I could get it to silently create a Lion-fullscreen second desktop without automatically switching to it, but I think this is about as good as it's going to be for now. I'll use this while looking to a more elegant solution. Thanks! – audiosnow Oct 21 '12 at 18:41

In case you still have this question, use this:

do shell script "open -ga 'iA Writer'"

open is a Terminal command that opens things. The -g option opens the app in the background. The -a specifies an app to open. If no files are provided, as here, open will simply open the app with no files. If you wanted to open a particular file, you could use do shell script "open -ga 'iA Writer' myfile.txt"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .