The window bounds are a list of coordinates {left, top, right, bottom}. You probably intended "400" to be the width, but it's the position of the right edge of the window and 400 is to the left of 1105, so you get a minimum width window. Change 400 to 1105 plus the desired width, e.g., 1505.
But before you pursue this further, Terminal has a better solution for this: Window Groups. If you set up a group of windows and save them as a Window Group, each time you open that group it will create windows with the same layout and appearance.
Window > Save Windows as Group…
You can even tell Terminal to open a selected window group at startup:
Terminal > Preferences > Startup > On startup, open: > Window group:
(As a shortcut, when creating a window group there's a checkbox for making it the startup group.)
To automatically run particular commands in those windows, you can create custom settings profiles and specify the command with
Terminal > Preferences > Settings > [profile] > Shell > Startup > Run command:
then create each window with the appropriate profile.
Going further, in Mac OS X Lion 10.7 you can have window groups automatically restore commands without creating custom profiles, by creating the terminals using
Shell > New Command
instead of running the command inside the terminal shell. When creating the window group, you can check "Restore all commands". (By default, it will restore a small set of "safe" commands, but you must explicitly tell it if you want it to re-run all commands when opening the group.)
Moreover, Lion Terminal supports Resume and will automatically restore all your windows each time you open Terminal. It will even restore "safe" commands for terminals created with New Command.
Note: The issue with delay
was fixed in OS X 10.11 El Capitan.
@2oh1, you have the right basic idea in your answer, but here's a complete and correct answer:
The only reasonable way to work around this is to invoke "delay" within a loop that ensures the desired duration elapses before continuing. The best way to do this is to override "delay" with a custom handler:
on delay duration
set endTime to (current date) + duration
repeat while (current date) is less than endTime
tell AppleScript to delay endTime - (current date)
end repeat
end delay
This enables you to leave the rest of your script unchanged and you can use "delay" normally, e.g.,
delay 5
display alert "I like cake!"
[NOTE: Normally, the custom handler would use "continue delay duration" to invoke the built-in "delay", but I found that, although this works within Script Editor, it returns an error when used within an applet (“Can’t continue delay. (-1708)”). I worked around that issue by directly telling AppleScript to handle the delay command instead of using "continue" to get there.]
The issue is that delay
processes user input while pausing the script, so you can still click on menus or windows displayed by an applet, and there is a bug (fixed in 10.11) where user input causes delay
to not wait the full duration before resuming script execution. If you don't interact with the applet, delay
works correctly.
Best Answer
In the AppleScript documentation for the
delay
command it says "the number may be fractional, such as 0.5 to delay half a second" yet doesn't specify a stated minimum time interval, however there is an interesting discussion statement at the end of the documentation for thedelay
command which accounts for the timing not being accurate.From the AppleScript documentation for the
delay
command: