Switching to a different Spaces window via a command in a shell script?

Hippo Man

Hippo Man
In Leopard, is there a command that I can invoke from within a shell script which will cause the desktop to switch its view to a specified Spaces window?

Thanks in advance.
.​
 
This doesn't answer your question directly. But, if your goal is to use keystroke entry method to switch between spaces windows, select a keyboard short cut from within System Preferences.
 
Thanks for your reply, but unfortunately, I'm not looking for a way to do this with a keystroke.

I have a shell script that does a number of things, and when it gets to a certain point in its processing sequence, I'd like the desktop to switch to a certain Spaces window.

I'm guessing that this is not possible, but who knows ... ?

Thanks again.
.​
 
Thanks for your reply.

I could use AppleScript, but I already have a rather involved shell script that I've been using, and I was hoping that I could just slip a command-line invocation into the appropriate place which would cause the desktop to switch to a different Spaces window.

If there's no way to do this from within a shell script, I guess I could rewrite the whole thing as an AppleScript program, or just abandon this idea altogether. It's not a critical task, just a "nice to have" kind of thing.
.​
 
If there's a way to do it with AppleScript (if there is, I'd love to know about it), you can execute it from a shell script using the osascript command. Here's an example of executing a simple AppleScript from a shell:
Code:
osascript -e 'tell application "Finder" 
return the name of window 1
end tell'
 
Thanks. I'm still learning MacOS X, and I didn't know about osascript.

Now, I'll do some investigation to see if there's a way to use AppleScript commands to tell Spaces or maybe Finder that I want to switch the view to another Spaces window.
.​
 
Well, I haven't been able to find any way to use AppleScript to tell Spaces to switch the space that is shown in the desktop. There is no dictionary for Spaces nor for Expose.

I looked through Finder's dictionary, and I couldn't find a way to do it there, either.

Can anyone think of any other places that I should look?

Thanks.
.​
 
There's a lot of AppleScript goodies in System Events: "/System/Library/CoreServices/System Events.app"

There are some commands for working with Spaces preferences, but I don't see a "move to space" command or anything like that.

The only idea I have is to have AppleScript simulate the keystrokes you have set to switch spaces, with the "keystroke" command of System Events.
 
Back
Top