Can I switch between windows of the same type using AutoHotkey?

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

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.


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.