Detect if window isn't active?

BlitzMax Forums/BlitzMax Beginners Area/Detect if window isn't active?

How would I detect when a window stops becoming active by, say, clicking on a different program's window? If GadgetDisabled(window)=True doesn't seem to work.