Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question

There's no code in 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?

share|improve this answer
+1 for the only realistic solution here, and for the last two sentences. – Sasha Chedygov Nov 17 '10 at 4:55

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

share|improve this answer
Yeah, but I meant single clicking to cycle through them. If it's possible to bind that somehow. – Krang Aug 9 '10 at 23:02

"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".

share|improve this answer

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"
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'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.

share|improve this answer
Except, of course, that when you click it, the real Safari is just going to pop up at the end of the dock anyway. – NReilingh Aug 21 '10 at 16:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .