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
looking4px
  • Guests
  • Last active:
  • Joined: --
So I know how to cycle windows like this....

GroupAdd, NOTES, ahk_class Notepad

^z::
GroupActivate, NOTES , R
Return

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?

camerb
  • Moderators
  • 570 posts
  • Last active: Feb 16 2014 03:38 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)
ids.=match1

!p::
WinGet, currentId, ID, A
needle=%currentId%\|(.{7})
RegExMatch(ids, needle, newId)
WinActivate, ahk_id %newId1%
return

!n::
WinGet, currentId, ID, A
needle=(.{7})\|%currentId%
RegExMatch(ids, needle, newId)
WinActivate, ahk_id %newId1%
return

You may need to change some parts of that code, but overall it should remain very similar.