Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

Cycle windows

  • Please log in to reply
1 reply to this topic
  • Guests
  • Last active:
  • Joined: --
So I know how to cycle windows like this....

GroupAdd, NOTES, ahk_class Notepad

GroupActivate, NOTES , R

What I would like to do is have a back as well as forward hotkey to cycle (in both directions) thru notes (example) can this be done?

  • Moderators
  • 573 posts
  • Last active: Sep 14 2015 03:32 PM
  • Joined: 19 Mar 2009
Yeah, you can easily cycle through windows. First you need to get a list of the ahk_ids in your group, then you need to determine which one is previous/next in line. You could loop through arrays and such, but I just used regex to do the second part.

;note: replace this with whatever you're using to make the group
SetTitleMatchMode, Regex
GroupAdd, TestGroup, ahk_class (Explore|Cabinet)WClass

;and perhaps you want to rename the Group, too
WinGet, id, LIST, ahk_group TestGroup
Loop, %id%
  ids .= id%A_Index% . "|"

;enable wrap-around
RegExMatch(ids, "^([0-9a-fx]{7}\|)", match)

WinGet, currentId, ID, A
RegExMatch(ids, needle, newId)
WinActivate, ahk_id %newId1%

WinGet, currentId, ID, A
RegExMatch(ids, needle, newId)
WinActivate, ahk_id %newId1%

You may need to change some parts of that code, but overall it should remain very similar.
Aren't you glad that I didn't put an annoying gif here?