Hey @grig,
That’s not so easy to do reliably.
Keyboard Maestro only sees a certain number of window types.
To get really reliable results you’d have to depend upon UI-Scripting with System Events.
Run this from the Script Editor.app to get an inkling of how this works:
tell application "System Events"
tell (first process whose frontmost is true)
tell front window
UI elements
end tell
end tell
end tell
Also — see my macros in this thread:
-Chris