Do you want to open 3 Terminal applications or 3 Terminal windows? To open 3 windows simply repeat the command(s) to open one window three times
Here an example how to open three Terminal windows and reference them via their ids:
set winIDs to {}
repeat 3 times
tell application "Terminal"
do script ""
set newWIN to (front window)
end tell
set winIDs to winIDs & id of newWIN
end repeat
set pos to 0
repeat with theID in winIDs
tell application "Terminal"
set bounds of window id theID to {pos, 10, pos + 360, 700}
set pos to pos + 360
do script "echo 'I am window " & theID & "'" in window id theID
end tell
end repeat
The Firefox version I use has a (rudimentary) AppleScript support. So you can open it with:
The problem is that your script is actualy opening 4 terminal windows. 3 that do the right thing, and then another… seemingly parent window. Any idea on that?
many thanks - Farid is right - I forgot Terminal’s behaviour to open a window at startup.
To avoid closing an existing window when you run the script and Terminal was already in use you could also use this modified script:
tell application "System Events"
if "Terminal" is not in (name of application processes) then
tell application "Terminal"
activate
close window 1
end tell
end if
end tell
set winIDs to {}
repeat 3 times
tell application "Terminal"
do script ""
set newWIN to (front window)
end tell
set winIDs to winIDs & id of newWIN
end repeat
set pos to 0
repeat with theID in winIDs
tell application "Terminal"
set bounds of window id theID to {pos, 10, pos + 360, 700}
set pos to pos + 360
do script "echo 'I am window " & theID & "'" in window id theID
end tell
end repeat
Ok great. Also, is there a decent way to position Firefox? setting the bounds doesn’t do a thing. I know it’s Applescript cababilities are limited, but maybe you guys know some tricks.
Did this work for you? With my Firefox I could only set the position («class pLcn») - ‘bounds’ were only readable
If you don’t succeed with Jacques’ idea you could try to resize the windows with JavaScriptlets - for example like this:
set scriptPath to ((path to me) as string) & "Contents:Resources:"
repeat with n from 1 to 3
set resizeIt to alias ((scriptPath & n & ".htm") as string)
tell application "Finder" to open resizeIt using (path to application "Firefox")
end repeat
save this script as ‘Program Bundle’ and add three files in it’s resources folder:
Sorry Jacques - I’ve checked it again and seen that I was trying with Firefox 1.0 (where I get an NSReceiverEvaluationScriptError: 4 with your script) … maybe I should update