I keep open many tabs in many windows in many applications on two screens. Often I want to go to a specific window — for example, the Safari window where I am on KM forum pages, or a music streaming service. (I try to keep all my KM forum pages open in tabs of one window, otherwise things get too disorganized even for me.)
In a list of Safari windows it is often difficult to find the one you are looking for, especially because the title may not begin with what you are looking for. (Discourse does this; although not the common practice, I think I prefer it, if for no other reason than better bookmarking/Evernoting.) You may also want simply to avoid a several-step dance and the interruption of reading window lists to get where you know where you want to go.
Here is my "go to the KM forums in Safari" KM macro. No, this is not hard to write, but maybe the idea or a detail will interest someone. I could inspire a fair amount of generalization and customization. (I already have several of these on a palette and need to turn the body of the macro into a submacro.
KM version:
AppleScript version:
tell application "Safari"
activate
set theWindows to the windows whose name contains "Apple"
if the (count of theWindows) is greater than 0 then
set the index of the first item of theWindows to 1
else
make new document with properties {URL:"https://forum.keyboardmaestro.com"}
end if
end tell