window_has_focus();
Returns: Boolean
With this function you can poll the window (or tab) state and if
it loses focus the function will return false otherwise it
will return true. In most cases you can simply use the
os_is_paused
function to test this, but in some very specific cases (for example
games on Chrome Apps) that function will not trigger, in which case
you should use this function instead.
NOTE: This function is only valid for the HTML5, Windows,
and MacOS modules.
if !window_has_focus()
{
scr_PauseGame();
}
The above code will check to see if the game window is in focus or not, and if the function returns false a script will be called.