全系统重点

是否有可能获得当前焦点窗口的HWND? 对于整个Windows站,而不是当前的应用程序。 目标应用程序是Win32。 我可以使用GetForegroundWindow()获取当前窗口,但是,这只是主窗口。 我可以枚举子窗口,但是如何确定它是否重点?

HWND RemoteGetFocus() { HWND hwnd = GetForegroundWindow(); DWORD remoteThreadId = GetWindowThreadProcessId(hwnd, NULL); DWORD currentThreadId = GetCurrentThreadId(); AttachThreadInput(remoteThreadId, currentThreadId, TRUE); HWND focused = GetFocus(); AttachThreadInput(remoteThreadId, currentThreadId, FALSE); return focused; }