If you know how to bind an applescript to keyboard shortcut/trackpad gesture, this is the answer for you.
The script is meant to be universal. It uses the most generalized terms to include as many scenarios as possible. I've tested on Finder, Script Editor, and Firefox. No errors.
However, it has caveats:
The script only works when there's only one instance of an app. (BTW, it still says "several instances" in the text of OP.) It's possible to work multiple-instance into it, but that's a fight for another day.
This script scrolls down the list of windows in
Window menu. It in essence clicks the item right below the one with a check ("✓") mark. If the item with a "✓" is the last item, the script will instead click the first item under the last separator line. A script that goes backward in the reverse direction can be obtained be modifying this script. However, I do not see how the two can be combined into a single script.
try statement that produces an
errorMessage is the most CPU-efficient way I know to produce the index of the
separator. If you know a better way, please enlighten me.
tell application "System Events" to tell (first application process whose frontmost is true) to tell menu bar 1 to tell menu "Window"
set cellingSeperator to last menu item whose value of attribute "AXEnabled" is false
set checkedItem to first menu item whose value of attribute "AXMenuItemMarkChar" is "✓"
set intentionalError to cellingSeperator as Unicode text
on error errorMessage
set firstItemIndex to (characters ((offset of "«class menI» " in errorMessage) + 13) through ((offset of " of" in errorMessage) - 1) of errorMessage as string as integer) + 1
repeat with iterator from firstItemIndex to number of menu items
if value of attribute "AXFrame" of menu item iterator is equal to value of attribute "AXFrame" of checkedItem then
set clickItemIndex to iterator + 1
if clickItemIndex is greater than number of menu items then set clickItemIndex to firstItemIndex
tell menu item clickItemIndex to perform action "AXPress"