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

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

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.