Here's a macro that monitors for changes to the frontmost window and lets you invoke an action "if it changes" and the term "if it changes" essentially means "if the number of unique words on the window differs from the last check by more than N words," where you can change the number N. For most purposes a number around 3 should suffice, but it depends upon your situation. You can use a larger number for N if you are getting some false positives.
IMPORTANT NOTE: an updated version (11.1) is found below. Please use that version.
Detect if Front Window Changes Macro (v11.0.1)