Execute script when window is unfocused

Is there a way to execute a script when the window loses focus?
Not while Graphics.update is being called, unfortunately.
Let's go theory-wise on this one. I'm not aware of how it'd work normally if at all, but how I would try and implement it...


Have a global for $active_window, and set it as you have different modals and other items. Find a way to attach reactive events in the graphics update for onChange and other types of hooks. This type of idea comes from .NET and Javascript, but could be ported here. Thoughts on practicality?
Do you mean $active_window as in the window/application that currently has the focus? Or are you referring to windows within RPG Maker? It could not change the $active_window variable, because by the time the current window is no longer active, the script has halted, and any line to change the variable would not be run.


Basically, when an RPG Maker game's window loses the focus, the scripts stop running. I'm not aware of any way to change that.

Original thread: https://forums.rpgmakerweb.com/threads/execute-script-when-window-is-unfocused.36023/