Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am looking to automate the launching of my workspace. I use several applications, carefully positioned across two monitors, and I would like to be able to launch my prefered layouts with a single click

I know how to launch several apps with an automator script, now I just need to be able to place the apps where they belong on the screen.

Many thanks.

share|improve this question
    
It's going to be more difficult because you use two monitors... Also, do you need to reposition multiple windows of the same application? Scripts like this don't tend to have a very long life span though. It could be more useful to break it down into actions for launching each application, and for setting bounds for windows. –  Lri Mar 14 '11 at 16:10
    
No, I just need to open textmate, terminal, a finder window and firefox, firefox takes up all of one monitor, with the others sharing the larger display. –  Mild Fuzz Mar 14 '11 at 16:30

2 Answers 2

up vote 1 down vote accepted

This, while possible, may be a bit too fiddly to do with a script. Here is a partial sample script that restores firefox and itunes windows (adapted from the script found here.)

property numFFWindows : 0
property FFPos : {}
property FFSize : {}
property iTunesPos : {}
property iTunesSize : {}

display dialog "Set Window Position or Save Window Position?" buttons {"Restore", "Save"} default button "Restore"
set theResult to result

tell application "System Events"
    if (button returned of theResult is "Restore") then
        -- Restore Settings
        if (numFFWindows > 0) then
            tell process "Firefox"
                repeat with i from 1 to numFFWindows
                    set position of window i to (item i of FFPos)
                    set size of window i to (item i of FFSize)
                end repeat
            end tell
        end if
        if (iTunesPos is not {0, 0}) then
            tell process "iTunes"
                set position of window 1 to iTunesPos
                set size of window 1 to iTunesSize
            end tell
        end if
    else
        -- Save Settings
        tell process "Firefox"
            set numFFWindows to count windows
            set FFPos to {}
            set FFSize to {}
            repeat with i from 1 to numFFWindows
                set end of FFPos to (position of window i)
                set end of FFSize to (size of window i)
            end repeat
        end tell
        tell process "iTunes"
            set iTunesPos to position of window 1
            set iTunesSize to size of window 1
        end tell
    end if
end tell

I suggest you to look at this utility for more flexibility:

http://cordlessdog.com/stay/

share|improve this answer
    
The stay app looks perfect. Thanks!! –  Mild Fuzz Mar 15 '11 at 16:21

Here's another example using Applescript:

tell application "Finder"
    set {0, 0, dtw, dth} to bounds of window of desktop
end tell

tell application "Finder"
    reopen
    activate
    try
        set bounds of window 1 to {0, 22, dtw / 2, dth / 2}
    end try
end tell

tell application "Safari"
    reopen
    activate
    try
        set bounds of window 1 to {0, 22, dtw, dth}
    end try
end tell

tell application "Terminal"
    reopen
    activate
    try
        set position of window 1 to {0, 22}
        set size of window 1 to {dtw / 2, dth - 22}
    end try
end tell

tell application "TextEdit"
    reopen
    activate
    try
        set bounds of window 1 to {dtw / 2, 22, dtw, dth}
    end try
end tell

Working with multiple monitors requires way too much wizardry though.

SizeUp has separate actions for moving a window to the next monitor and setting bounds for windows.

share|improve this answer
    
Is it deliberately incomplete? dtw/dth (desktop width/height I think) are undefined. –  Daniel Beck Mar 14 '11 at 21:26
    
@Daniel They're on the second line of the script. :) And let's add it here, so it won't seem like I edited the post to add the dtw and dth — I just bumped into this while reading DF archives: Daring Fireball: Getting the Size of Your Display With AppleScript, the Lazy Way. It shows how bounds of window of desktop fails with multiple monitors. –  Lri Mar 14 '11 at 22:26
    
OK -- These lines looked just like the rest when I read it the first time. Nice find. –  Daniel Beck Mar 15 '11 at 6:51

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.