Switching between running applications

Discussion in 'AppleScript' started by MorganNews, Sep 29, 2008.

  1. MorganNews

    MorganNews New Member

    Joined:
    Sep 29, 2008
    Messages:
    6
    Likes Received:
    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
     
    MorganNews, Sep 29, 2008
    #1
    1. Advertisements

  2. MorganNews

    Spawn_Dooley Moderator

    Joined:
    Jun 13, 2007
    Messages:
    2,714
    Likes Received:
    79
    Location:
    van diemen's land
    Hello MorganNews and welcome to the forums:)

    Have you tried Command + Tab to switch between open apps?
     
    Spawn_Dooley, Sep 29, 2008
    #2
    1. Advertisements

  3. MorganNews

    MorganNews New Member

    Joined:
    Sep 29, 2008
    Messages:
    6
    Likes Received:
    0

    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.
     
    MorganNews, Sep 29, 2008
    #3
  4. MorganNews

    Spawn_Dooley Moderator

    Joined:
    Jun 13, 2007
    Messages:
    2,714
    Likes Received:
    79
    Location:
    van diemen's land
    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?



    .
     
    Spawn_Dooley, Sep 29, 2008
    #4
  5. MorganNews

    Walrus666 Moderator

    Joined:
    Jul 21, 2007
    Messages:
    1,252
    Likes Received:
    15
    Location:
    Chicago
    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.
     
    Walrus666, Sep 29, 2008
    #5
  6. MorganNews

    MorganNews New Member

    Joined:
    Sep 29, 2008
    Messages:
    6
    Likes Received:
    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
     
    MorganNews, Sep 29, 2008
    #6
  7. MorganNews

    MorganNews New Member

    Joined:
    Sep 29, 2008
    Messages:
    6
    Likes Received:
    0
    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
     
    MorganNews, Sep 30, 2008
    #7
  8. MorganNews

    teapot New Member

    Joined:
    Nov 28, 2005
    Messages:
    228
    Likes Received:
    3
    Location:
    Kendal UK
    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
     
    teapot, Oct 1, 2008
    #8
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.
Similar Threads
  1. Matt5867

    switching between Chinese and English

    Matt5867, Oct 27, 2008, in forum: Mac OS X
    Replies:
    0
    Views:
    736
    Matt5867
    Oct 27, 2008
  2. Nelson Lu
    Replies:
    0
    Views:
    357
    Nelson Lu
    Oct 11, 2003
  3. Graeme Forbes
    Replies:
    2
    Views:
    230
    Graeme Forbes
    Oct 31, 2003
  4. Dave S

    Switching between OS

    Dave S, Apr 8, 2008, in forum: Apps
    Replies:
    2
    Views:
    253
    dorayme
    Apr 9, 2008
  5. Sawney Beane

    switching between dialup and dsl

    Sawney Beane, Apr 4, 2006, in forum: Communication
    Replies:
    1
    Views:
    188
    Sawney Beane
    Apr 4, 2006
  6. Jacob Feldman
    Replies:
    2
    Views:
    281
    Christoph Gartmann
    Nov 8, 2004
  7. Mitch Hall
    Replies:
    0
    Views:
    434
    Mitch Hall
    Oct 26, 2003
  8. miketaylor75@hotmail.com

    Switching between Airport and wired Ethernet

    miketaylor75@hotmail.com, Jan 12, 2008, in forum: Mac
    Replies:
    18
    Views:
    319
    jack ak
    Feb 26, 2008
Loading...