Get window handle of last activated window

匿名 (未验证) 提交于 2019-12-03 03:03:02

问题:

I am developing an application that sits in the system tray and can perform actions on the active window. But when the icon in the system tray is clicked, GetForegroundWindow() returns the taskbar. I need to get the window that was active before the taskbar was.

I've tried enumerating the desktop window with EnumWindows and GetWindow, but this is often turning up desktop gadgets and other top items that where not active last. Is it even possible, or the information completely lost when the window is deactivated?

回答1:

I think the only way to get that info is by installing a system wide hook (SetWindowsHookEx) on WH_CALLWNDPROC and capturing all WM_ACTIVATEAPP. This will even enable you to track the full history of which window was active when.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!