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?