Switching between running applications

Joined
Sep 29, 2008
Messages
6
Reaction score
0
I'm a new Applescript user who is trying to accomplish what I thought was something easy: Switch from one application to the one I was using immediately previously.

For example, if I have switched from Safari to Mail, and I want to switch back to Safari again. I want an Applescript to pay attention to which application I was previously in, and, when I activate the script, switch me back to the one I was just using. If I activate it again, I want to be switched to the other application I was in, because it's now the previous application.

Is there someway to accomplish what I want to do using AppleScript? I don't have enough experience in Applescript to figure out the script necessary to accomplish the task. I've searched the net without finding a script to dowhat seems like something people would need a lot, but...

My basic thought was to get the name of the current application, save it to a variable, switch to the previous application, which was stored in a different variable, swap the two variables. But I began having issues with what the 'current application' was, as far as Applescript was concerned, and swapping.

But there also seems to be a chicken-and-egg situation developing in getting the first pass through.

Or maybe that's not the way to tackle the problems.

Can anybody help?

Thanks.

/ Peter Morgan
 

Spawn_Dooley

Moderator
Joined
Jun 13, 2007
Messages
2,849
Reaction score
93
Hello MorganNews and welcome to the forums:)

Have you tried Command + Tab to switch between open apps?
 
Joined
Sep 29, 2008
Messages
6
Reaction score
0
Hello MorganNews and welcome to the forums:)

Have you tried Command + Tab to switch between open apps?


Hey, thanks for the welcome!

Yes, I know about that shortcut, but when you've got more nine or 10 apps running, you have to (a) scroll (b) think to yourself: "No, not that one; no, not that one; no, not that one...". And when you do it repeatedly, such as when you're copying something from one window of one app to another window of another app, it gets downright annoying.

The point, at least for me, is to flip between two apps with one keystroke, no scrolling, no mousing, no mumbling.
 

Spawn_Dooley

Moderator
Joined
Jun 13, 2007
Messages
2,849
Reaction score
93
... when you've got more nine or 10 apps running ...

Wow! You must be a power user MorganNews ;)

I'm not sure if an AppleScript would be easier that Command + Tab .... but it might work ... I am no expert in this field but check back later as Walrus666 is pretty deft at scripting ... see what he thinks , is my suggestion :)

I just thought of Expose, have you tried using that? I think it's keyboard shortcut is F9? Also if you press Command + Tab, you don't need to scroll, you can use your mouse and click an apps icon.

I just opened up 10 apps BTW, just to see what it'd be like.

There may be a modification that we can suggest to make things more productive if you tell us exactly what you usually need to do that requires fast App switching ... is it mainly copy/pasting?



.
 
Joined
Jul 21, 2007
Messages
1,243
Reaction score
15
Hello, Not that it can't be done but I can't picture an AppleScript that would be more efficient than Expose at doing this. In Expose, make sure that one of the corners is set to "All Windows" if you haven't already and you should be in business. If you want to save one step and have no desire to use Expose, you can click on the app that you want to bring to the front by clicking its icon in the dock. The only difference is that you would have to make the selection but if you were to come up with an AppleScript that could do this automatically, you would still have to take the time to activate and, or reactivate the script.
 
Joined
Sep 29, 2008
Messages
6
Reaction score
0
Thanks for your comments.

Yes, I'm an editor, with a serious genealogical hobby. There are times when I do quite a bit of copying and pasting of material from:

* Various sources for quotes for news stories -- or just flipping between a source document and the program I'm using to write the material to check a fact, the spelling of a name, to copy a person's job title, often from PDF, web or other types of documents;

* For excerpts of the stories I'm editing, so I can e-mail and ask various reporters what they mean by some phrase or sentence, or to check with them that a change I've made is OK with them;

* When I'm working on my hobby, a lot of bits and pieces -- names of towns, names of people (first name, say, from a document, into a specific field of my genealogical program's database, surname, birth place town's name, birth/marriage/death date... there's _a lot_ of that.

I've tried Expose, but... well, I just tried it now and I've got 23 windows wallpapering my screen. When moving back and forth, I have to pause _between each flip_ to visually identify the window I want and then move my mouse to choose it. And while the location of the windows might remain stable for a few minutes, it moves whenever I open or close a window.

/ Peter Morgan
 
Joined
Sep 29, 2008
Messages
6
Reaction score
0
I'm not sure if an AppleScript would be easier that Command + Tab
.

I'm wondering if perhaps I may have misunderstood this particular comment, SD.

Until about 15 minutes ago, I was under the impression that Command-Tab only called up a bar of large running-app icons, from which I then had to choose one with a mouse selection, or let the system cycle the selection on the bar, and that was what you meant by your comment.

Fifteen minutes ago, however, was when somebody told me in passing that simply hitting Command-Tab and then letting go would flip OS X's attention from the current front app to the previous front app -- which is exactly what I want.

It's even (blush) documented, in the Command-Tab pane of the Finder's Help files: "You can quickly switch from the current application to the last application used by pressing Command-Tab (and releasing the keys)."

So, once again, Apple's programmers are so far ahead of me, I think I'm first.

I'll slink off now...

/ Peter Morgan
 
Joined
Nov 28, 2005
Messages
228
Reaction score
3
Hi Morgannews
I have used logitech multi button mouse or mice for some years now and I have 1 f the buttons programmed to launch the app switcher then just click on the app I need to go to
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top