Get a list of current windows and give one of them focus, in .Net

Without resorting to PInvoke, is there a way in .net to find out which windows are open? This is slightly different from what applications are running in memory. For example, Firefox may work, but there may be more than one window. Basically, I just want to be familiar with the same information as the taskbar (and alt-tab?).

Also, as soon as I have a link to a window, is there any way to programmatically give it focus?

Is there a way to do this using managed code?

+3
source share
3 answers

You can check out the new UI Automation in .NET 3.5. It is assumed that it will mask all PInovke stuff and work with web applications and WPF applications.

, , , .

+1

LGPL. , . aku . , , pinvoke.

http://mwinapi.sourceforge.net/

pinvoke:

http://www.pinvoke.net/

+1

I am afraid that you cannot do this without PInvoke. To focus on a window, you must call the SetForegroundWindow function, see this article for details.

0
source

Source: https://habr.com/ru/post/1696602/


All Articles