OS X dock, switch between application's open windows by clicking on its dock icon?

1

1

Let's say I have Safari active and I want to cycle between its open windows by pressing Safari's dock icon (instead of pressing cmd+>).

Is it possible to accomplish this somehow?

Krang

Posted 2010-08-09T22:41:23.340

Reputation: 11

Answers

1

There's no code in Dock.app to do this. command+` is the normal way to cycle through an application's open windows. If you want to cycle by clicking a dock icon, you could write an AppleScript to hit that keystroke and put that in the dock right next to Safari.

tell application "System Events"
    keystroke "`" using {command down}
end tell

Put the above into AppleScript Editor, and save it as an application. It won't work unless we prevent it from stealing focus, which can be accomplished by right-clicking the app bundle and showing package contents, open Contents/Info.plist, and then add the LSBackgroundOnly key (Application is background only) with a boolean value of 1. Add it to the dock and click it to execute that keystroke. It'll work for any application.

I find it a bit strange that you would think this is necessary or possible completely out of the blue. Is there something bigger that you're trying to accomplish with this?

NReilingh

Posted 2010-08-09T22:41:23.340

Reputation: 5 539

+1 for the only realistic solution here, and for the last two sentences. – Sasha Chedygov – 2010-11-17T04:55:31.467

0

You can right click on the dock icon and the menu will list all of the applications open windows.

Benedict Lowndes

Posted 2010-08-09T22:41:23.340

Reputation: 474

Yeah, but I meant single clicking to cycle through them. If it's possible to bind that somehow. – Krang – 2010-08-09T23:02:50.973

0

"Cmd >" ?

Why not use "Cmd `" (backtick, the key above the Tab), which is the standard one to cycle between windows for any app? If not, then you want to "bind" to something that you can single-click?

Edit: an easy built-in mouse-only approach is to set a Hot Corner in the System Preferences to show all Application Windows, then you can click on the one you want. But that doesn't "cycle".

Ken

Posted 2010-08-09T22:41:23.340

Reputation: 7 497

0

The wanted behaviour can be achieved by replacing the Safari's icon in the dock with the following AppleScript (following NReilingh's example) saved as an Application:

tell application "Safari"
    activate
end tell

tell application "System Events"
    keystroke "`" using {command down}
end tell

That will focus Safari and cycle through its active windows. If Safari is not open, it will be opened on the first time, so this works also like the normal Safari icon.

To complete things you need to edit the script's properties - right click the script app in Finder and select Show Package Contents, then open Info.plist in Contents.

  • You need to add the LSBackgroundOnly (Application is background only) key with Checked value (as without that key the cycling doesn't work properly and the icon will just toggle two of the most recent window).
  • To get the authentic Safari icon you can copy/paste compass.icns from Safari.app's Contents | Resources to the corresponding place of the new script's. After that change Icon file property to point to the new icon.
  • After changes save the propertylist file.
  • It may be necessary to resave the script as well.

Now you should have an icon in dock that looks like Safari's but with added window cycling with subsequent clicks - if you named the script as Safari, nobody should notice any difference with original.

Jawa

Posted 2010-08-09T22:41:23.340

Reputation: 3 349

1Except, of course, that when you click it, the real Safari is just going to pop up at the end of the dock anyway. – NReilingh – 2010-08-21T16:32:07.763