The GetForegroundWindow function returns the handle of the foreground window (the window with which the user is currently working). The system assigns a slightly higher priority to the thread that creates the foreground window than it does to other threads.
HWND GetForegroundWindow(VOID)
Parameters
This function has no parameters.
Return Values
The return value is the handle of the foreground window.
See Also