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?