Create a command to focus a specific window from anywhere in OS

applescriptwindow-manager

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.

Best Answer

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.