Ander Posted October 24, 2017 Author Share Posted October 24, 2017 As I mentioned before, when I'm logged into the PC, I can use winActivate and send commands without any problems. My actual problem is when I am not logged into the PC given that AutoIt cannot manage the GUI the same way. I tried to use other commands like ControlFocus, yet I got the same outcome. $remoteDesktopName = "'Cli123456-VM - Remote Desktop Connection" ControlFocus($remoteDesktopName, "", "[CLASS:OPContainerClass; INSTANCE:1]") Sleep(500) My understanding is that when the PC is locked any session is active, therefore AutoIT is unable to manipulate the GUI. Thanks. Link to comment Share on other sites More sharing options...
Earthshine Posted October 25, 2017 Share Posted October 25, 2017 (edited) I found this on Stack Overflow, says you need to activate the window. https://stackoverflow.com/questions/26505329/autoit-controlsend-remote-desktop I just tested this by 1. Starting a VM 2. RDP to VM 3. Lock said VM 4. From remote client, run the test below, Substitute the correct Title to search for and the correct password in place of Hello1 and you are all set! #include<Array.au3> OPT("WinTitleMatchMode",2) $a = WinList("Remote Desktop Connection") ;_ArrayDisplay($A) ConsoleWrite(UBound($A)& @CRLF) FOR $N = 1 to $A[0][0] $hActiveWindow = WinGetHandle("") WinActivate($a[$N][1]) ;comment if using controlfocus ;ControlFocus($a[$N][1],"","") ;comment if using winactivate ControlSend($a[$N][1],"","","Hello1^+{ENTER}") WinActivate($hActiveWindow) Next This code finds the RDP Sesseion Next it activates the found RDP session at element $a[$N][1] Next it sends that found control some keystrokes Next it activates that TscShell class (RDP window) so the code can execute. Sorry this took so long to answer. This should do ya. Edited October 25, 2017 by Earthshine My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
Ander Posted October 30, 2017 Author Share Posted October 30, 2017 Hi Earthshine, Thanks for all your support, unfortunately I could not get the script working. When I run the script with my local machine locked, the script just sends the enter but it does not Activate the "Remote connection" window, as a result, the script in the remote PC doesn't run either. Thanks. Link to comment Share on other sites More sharing options...
jdelaney Posted October 30, 2017 Share Posted October 30, 2017 (edited) use paexec to run the script on the remote desktop...then you can use reliable functions. It will by default run in session 0, which is where services run. Gui's will still be created, but several functions are not possible to use in that state. windows can not be in an 'active' state when behind a locked desktop. https://www.autoitscript.com/wiki/FAQ#Why_doesn.27t_my_script_work_on_a_locked_workstation.3F Edited October 30, 2017 by jdelaney Earthshine 1 IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
Earthshine Posted October 31, 2017 Share Posted October 31, 2017 thanks jdelaney! I may even need this functionality some day. My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now