質問

I would like to know if there is some way to pass the window handle of the window that was active before my application was started (either through a click on the taskbar icon) or a double click on my application's icon on the desktop.

I guess this is not possible, but I wanted to ask anyway.

Thank you for the help!

役に立ちましたか?

解決

Strictly, the window that was active immediately before yours was the shell. Your application was started by the shell, and what you are really asking is what was the application that was active before the shell. Now that's an ask!

It's easy to enumerate the top level windows, which is basically what the shell does to give you the task list. That gives you a list of candidates. Not so easy to know which one, although the order in which they are returned could be a clue.

It's also relatively easy to get the Z-order for the running applications. It's highly likely that the application that was running before yours is the one with the highest Z-order, excluding your app and the shell.

My guess is that would be close enough for most purposes. After that I'm out of ideas.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top