Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

While developing for the web I tend to jump back and forth between my text editor and the browser a lot. I'd like to set a keyboard shortcut at the OS level that allows me to jump to a specific, definable window every time. Even better would be the ability to issue a tell that application to execute something, but I'll save that for later.

Are there technologies available that will let me do this? There must be something between C and AppleScript that let's me create this kind of an interaction. Does anybody know where to begin?

Thanks.

share|improve this question

3 Answers 3

up vote 0 down vote accepted

You should give Automator a try. You could "Record" a new service (that you can later publish for all Apps and assign a Keyboard Shortcut), that clicks the app from the Dock. In fact, you could add more actions and perform your "tell that application to execute something".

I've tried creating one (that is relatively useless but works) that clicks on Mail in my Dock, then clicks the get new mail icon in the toolbar. Fun ;)

Attached is the shot of the Automator result:

Automator

I used the Record button on the top right corner and then did the actions myself (clicked on the Mail's dock icon, then clicked on Mail's Get New Mail icon in the toolbar, then clicked "Stop Recording"). Please notice I've selected "Service receives [no input]" in the first combo box, as I wasn't interested in any input.

This gives you multiple possibilities to have a couple of services that go back and forth your TextEditor and your Browser.

Automator is located by using Spotlight and typing Automator (also located in /Applications/Automator.app)

In this case I've created a new "Service" but you could probably get away by creating "scripts". Not sure which one would be faster tho. Experiment. Automator is your friend.

share|improve this answer

You might do something like this with AppleScript:

tell application "Terminal"
    activate
    windows where name contains "bash"
    if result is not {} then set index of item 1 of result to 1
end tell

Or using System Events:

tell application "System Events" to tell process "Terminal"
    set frontmost to true
    windows where title contains "bash"
    if result is not {} then perform action "AXRaise" of item 1 of result
end tell
share|improve this answer

I use BetterTouchTool for setting different keyboard shortcuts or trackpad gestures on Mac OS X. One of the actions it can launch is Execute Terminal Command

So in the settings of the command I provide following:

osascript -e 'tell application "NameOfTheApplicationHere" to activate'

Here is an example from the BetterTouchTool preferences:

enter image description here

share|improve this answer

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.