Setting focus to window in a virtual machine
I am currently having issues getting a window to be the focused or active window in a virtual machine. It works fine when I have remote desktop connection open but when it's closed and i reopen the VM after running my code the window that I'm trying to focus on is greyed out as if it doesn't have focus. I'm trying to simulate key presses in an application which is why I need the window to be focused, does anyone know of a workaround for this? My application is written in C# and I'm trying to use some P/Invoke's to set the focus (which works when the RDP connection is open but fails 开发者_运维技巧otherwise).
It is possible by opening command prompt and typing : tscon.exe (your session id) /dest:console
This will disconnect you from your session and leave your desktop unlocked allowing the calls to work just in case anyone was wondering.
精彩评论