Jump to content

ControlSend interaction with RDP/Remote Desktop


Recommended Posts

Hi!

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

CODE
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")

WinWaitActive($title)

$handle = WinGetHandle($title)

If @error Then

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

Else

Sleep("3000")

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

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

EndIf

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!

-Varun

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...