5

I know how to create an AutoHotkey script to switch to (say) a Firefox window.

But suppose I have a number of Firefox windows open. I would like the key to switch to the next window each time it is pressed.

Edit - firefox was just an example. It could be PuTTY windows I wanted.

justintime
  • 3,261

3 Answers3

7

Try the WinActivateBottom command instead of WinActivate.

This activates the LEAST recently used window - and seeing as when you activate that, it's no longer the least recently used, this can be used to loop through every window.

; This hotkey WIN+A allows you to visit all open Firefox windows in order from oldest to newest:
#a::
SetTitleMatchMode, 2
WinActivateBottom, - Mozilla Firefox
return
Snark
  • 32,599
Phoshi
  • 23,383
  • 1
    Interesting idea. My feeling is the one at the bottom is likely to be the least interesting window to go to. – justintime Apr 02 '10 at 20:09
  • @justintime: Very likely. You could also use WinGet to retrieve a list of windows, and then do with that what you will - but I've not used that myself. – Phoshi Apr 02 '10 at 20:15
  • 1
    I have taken you answer as a starting point. If you are already on a n active Firefox window send it to bottom and then go to what is now the top. – justintime Apr 02 '10 at 20:30
  • @justintime Can you share that script? – Noumenon Jan 23 '19 at 23:44
2

If the reason you're trying to make an AutoHotkey script for this is simply because you don't think that functionality is available by default, then you may want to look at my post over at Windows Shortcut/Utility to switch between application windows. This functionality is actually already baked into Windows 7 and 8.

Robert
  • 381
1

Here's how this can be done.

  1. get active window title and class.
  2. get a list of all windows of that class.
  3. switch to the next window in that list.
aMoLk
  • 11