- regarding your Q in the OP:
As an AHK user, I did a duckgo search for info on this: autohotkey - detect change in window
- and some of the results looked potentially useful.
For example, including:
- Method to detect active window change?
- Run script on active window change
I also did a duckgo search on this: event viewer - detect change in a window
- as I wondered whether that might be an easy avenue to pursue (anything that occurs in the system could probably be defined as an event).
Not sure whether the results would be useful though, as I know little about triggering/viewing system events, though I am aware that several third party applications "log" events to the viewer and subscriptions can also be enabled - e.g., for remote PCs or dual monitors. It seems to be a pretty sophisticated component of the OS.
Hope this helps or is of use.