简体   繁体   中英

SetForegroundWindow in Remote Desktop Connection

I have an application in C# which sends keys to another program. To do that I call SetForegroundWindow method before sending keys which works. Problem is when I am connected to the computer using RDC and minimize the RDC window or disconnect it then keys are not sent.

It happens because when in RDC mode, SetForegroundWindow method doesn't work in minimized or disconnected state. I have tried using SetActiveWindow, SetFocus and BringWindowToTop but no luck. Is there any way to do that?

This is very common problem. When you disconnect or minimize the RDP window, GUI context is lost. But you can keep RDP non-minimized (focus can be lost safely). In other words just turn full-screen mode off and switch to another window if you want to continue work locally.

In our company testing teams use master-slave approach: master host initiates remote connections and keeps them non-minimized until each GUI automation task is done.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM