How do I bring up the Application Switcher interface in order to select an application (done manually by pressing the “Command” key and the “Tab” key at the same time?
If I utilize a script such as this:
Application Switcher does work, but it only switches to one, previous application (this occurs in Leopard - I believe I read that this is an issue/default setting with this operating system…the Application Switcher running backward when application selecting) and does so lacking the Application Switcher interface (manually holding down the “Command” and “Tab” keys at the same time).
I’ve also attempted this script:
But all I get is a textual “a (tab-space)”.
This is proving aggravating as, to me, this question is VERY basic. Scripting the Application Switcher seems as if it is something easy to access. I’ve gone through numerous searches only to end up with hundreds of pages of results with very little way to limit the search for something as basic as the Application Switcher.
I do, sincerely, appreciate any words of wisdom as to how to proceed with the script, how to locate a solution within these forums or even how to locate a solution on Apple’s Discussion group.
Thank you!
Model: G4 Dual Processor 1GHz
AppleScript: 2.0.1
Browser: Firefox 3.0.1
Operating System: Mac OS X (10.5)
tell application "System Events"
delay 0.5
key down command
keystroke tab
delay 10
key up command
--set proc_name to first process whose frontmost is true and visible is true
--set visible of (every process whose frontmost is not true and name is not "Finder") to false
end tell
The commented lines will hide (most) other apps if desired.
No. I just need Application Switcher (AS) to open. I am utilizing the AS with a Keyspan Remote Control. I am custom-mapping Applescripts to various keys and it is much easier with the Keyspan Remote Configuration software to utilize Applescript for some events.
I like simple. I can build on that.
Peter Bunn,
That script failed to work. I ran the script from Script Editor and all I got was the usual “a (tab-space”). I then saved the script as an application and ran it, but nothing happened.
Yes, I do have have “Enable Access for Assistive Devices” checked in the Universal Access Preference Pane.
Peter Bunn,
Thank you so much for the follow-through! I have a startup disk with 10.4.11 on it and I rebooted my computer into that system. I ran the script you gave and, lo-and-behold, it worked! Hooray. I then saved the script as both a regular Applescript file, as well as saving the working script as an application. I opened the script up in Script Editor in Leopard (10.5.4) and this is what I got:
Somehow, the “command” text is being translated into something else in Script Editor and/or Applescript 2.0.1 in Leopard (at least on my PPC machine). The saved application, however, did execute successfully in the Leopard environment, so I am able to make good on the code. I do wish I knew what the deal was with the Applescript in Leopard, however.
I think I am going to take this problem to the Apple Discussion Board group.
I have accessibility to an Intel machine at work and I ran the above code on that machine, which is running Leopard:
tell application "System Events"
delay 0.5
key down command
keystroke tab
delay 10
key up command
--set proc_name to first process whose frontmost is true and visible is true
--set visible of (every process whose frontmost is not true and name is not "Finder") to false
end tell
I ran into my same original problem - being returned a line of text, “a (tab-space)”. I think there is a problem in Leopard as the problem was replicatable on duplicate operating systems (Leopard - 10.5.4) on differing machines (one PPC and one Intel machine).
I have, finally, solved my issue and have programmed a remote control to control my “Application Switcher” commands. This allows me to switch to any active application within any application. The process is actually stupifyingly simple, but requires three, separate buttons to be utilized on the remote control. It would be nice to utilize one or two buttons to complete the task, but due to the lack of “listener event” capability within Applescript, I think that is hardly possible at this point-in-time.
Basically, I created three, separate scripts that are executed with the press of three, separate buttons:
Initializer
tell application "System Events"
key down command
end tell
Selection
tell application "System Events"
keystroke tab
end tell
Terminator
tell application "System Events"
key up command
end tell
I certainly welcome any efficiency suggestions or any comments regarding improvement of the method in use. Yes, yes, I know there’s “Front Row”, but that fails to address system-wide applications. I’m working toward an “Application Switcher” solution.
Thanks for all the help!
Model: Mac Pro
AppleScript: 2.0.1
Browser: Firefox 3.0.8
Operating System: Mac OS X (10.5)
The only way for your solution to work is to use the “key down” command, which can be dangerous. Make sure you put a lot of error checking in to make sure that the “key up” command will always happen. If you cancel the script or otherwise stop without “key up” the command key will stay pressed even after the script is done running! If that happens you have to figure out how to get back in script editor to execute a key up command, which is tricky when your command key is stuck on.
Thank you for your response. The “key down command” is hardly dangerous…it’s more like a nuisance.
In working to build my resolution, I came across this problem more than several dozen times and had to restart my computer each and every time, so I’m well aware of the difficulties that three separate key commands may produce; hence, my query into a more efficient solution.
I’ve built and applied the separate application sequences into my Keyspan Remote Configuration panel and it works flawlessly. Granted, I have to make sure to instantiate the “key up command” process each and every time, but the resolution works.
Model: Mac Pro Quad-Core Xeon 3.2 Ghz
AppleScript: 2.0.1
Browser: Firefox 3.0.8
Operating System: Mac OS X (10.5)