ThisSpace
One of the first things that happened to me in Spaces that irked me was its auto-switching to another space when I didn’t want it to. Sure, that’s probably what I’d want it to do a lot of the time, but if I’m trying to open a new window for an app that already has windows in other spaces, I have to select that app, create a new window, grab its title bar, and move back to the space I was in when I selected the app.
I was wondering what would happen if you could create a new window without activating the app, so I typed this into Script Editor:
tell application "iTerm" set term to (make new terminal) tell term launch session "default session" activate end tell end tell
The result is a brand new iTerm window in my current space, without regard to whether there might already be such a window in another space. Switching spaces from a script is pretty easy too — as long as you aren’t holding down any modifiers when the script runs (say, by having used command-r in Script Editor):
tell application "System Events" delay 1 -- so I can let go of command keystroke "2" using control down delay 1 -- so you can see one switch happen and then the other key code 125 using control down end tell
The one missing piece is moving a window — I don’t think it’s possible to drag an object via GUI scripting, so you can’t grab the title bar of a window, switch spaces, and then release it. At least it might be possible to create a fairly complex setup from a login script…if you had a lot of time on your hands. :)
AppleScript | Tagged Leopard, Mac OS X | Permalink | 2 Comments
November 8, 2007
at 12:32 pm

