I wrote a .NET winform app and set TopMost property to true. But I found that when I loggin to a remote destop, the window is still showing.
How to detect whether I'm in remote destop(remote desktop is active, typing/working in remote desktop) using .net framework? I am using .NET framework 4.8 and remote to Windows 10 1809 from Windows 10 1903
You probably have to call the Windows API with P/Invoke to achieve this. I could imagine it working roughly like this:
The foreground window has changed. The system sends this event even if the foreground window has changed to another window in the same thread. [Source]
Here's a good starting point on how to implement what I explained above: Detect active window changed using C# without polling.