System.onActivate

Function/Meaning
When the application becomes active
Type
Property of System class (read/write)
Description
Represents the event function called when the application becomes active.
If null is specified, the function will not be called.
Unlike normal event handlers, if you want to receive this event, set the function you want to call to this property.
Window.onActivate occurs when each window within the same application becomes active, but this event occurs when the main window becomes active.
Note that this event may occur even if the main window is already active (there is no guarantee that it will occur strictly in the order of onActivate -> onDeactivate -> onActivate -> ...).
Reference
System.onDeactivate
Window.onActivate
Window.onDeactivate