Is there an analog of _NET_WM_USER_TIME
property in Win32 or other way to get list of windows sorted by last used time?
1 Answers
There's the EnumWindows call, which lists all of the windows on-screen at any given time:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms633497(v=vs.85).aspx
Secondly, GetActiveWindow will give you the top-level window currently active, and GetFocus the window with input focus:
How can I tell if a Window has focus? (Win32 API)
There's no way to get a list of focus history from the Win32 API - it's a pretty niche bit of information! - but you can run a process on a background thread which periodically iterates through the results of EnumWindows, compares the handle to GetActiveWindow and stores a log over time of windows and focus statuses. That way, you'll be able to interrogate your very own log whenever you want without additional overhead.
I used to do much the same thing from Visual Basic back in the pre .NET days, but the same should be perfectly possible from any other environment which can get to the Win32 API.

- 1
- 1

- 2,034
- 1
- 14
- 15