GetActiveWindow function (winuser.h)

Retrieves the window handle to the active window attached to the calling thread's message queue.

Syntax

HWND GetActiveWindow();

Return value

Type: HWND

The return value is the handle to the active window attached to the calling thread's message queue. Otherwise, the return value is NULL.

Remarks

To get the handle to the foreground window, you can use GetForegroundWindow.

To get the window handle to the active window in the message queue for another thread, use GetGUIThreadInfo.

Requirements

Requirement Value
Minimum supported client Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header winuser.h (include Windows.h)
Library User32.lib
DLL User32.dll
API set ext-ms-win-ntuser-window-l1-1-4 (introduced in Windows 10, version 10.0.14393)

See also

Conceptual

GetForegroundWindow

GetGUIThreadInfo

Keyboard Input

Reference

SetActiveWindow