Jump to content
Sign in to follow this  

ControlSend interaction with RDP/Remote Desktop

Recommended Posts



I am trying to write a script to enter a password in an RDP session login box:

Opt("SendKeyDelay", 250)

Opt("WinTitleMatchMode", 4)

Const $title = "ED - x.x.x.x - Remote Desktop"

Const $id = "[CLASS:UIMainClass; INSTANCE:1]"

Run("mstsc ""Connection.rdp"" /f")


$handle = WinGetHandle($title)

If @error Then

MsgBox(4096, "Error", "Could not find the correct window")



$ret = ControlSend($handle, "", $id, "password{ENTER}")

MsgBox(0, "Password Entry", $ret)


The message box displays "1" - that is - success, but no data is entered into the password text entry field. Strangely enough, if I use a simple "Send" instead of "ControlSend", things work as expected - "MouseClick" also works as expected.

Some of the other things I have tried:

1. Using "UIMainClass1" and "[CLASS:UIMainClass]" as the control identifiers

2. Calling "ControlFocus" before "ControlSend"

3. Using the title of window in "ControlSend" instead of the handle

So, AutoIt guru's - here's the question - why?

BTW, I realize there might be other ways of passing the login information to the RDP login session, but I would really like to find out why this is not working as expected.

Thanks In Advance!


Share this post

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.