0

I have opened an RDP session using AutoIt. Here is the code:

$host = "" ; <---- IP 
$hGUI = GUICreate("Terminal Serveur", 952, 675, -1, -1, $WS_OVERLAPPEDWINDOW + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN)
$oRDP = ObjCreate("MsTscAx.MsTscAx.2")
$oRDP_Ctrl = GUICtrlCreateObj($oRDP, 64, 44, 800, 600)

GUICtrlSetResizing(-1, $GUI_DOCKALL)
GUICtrlSetStyle($oRDP_Ctrl , $WS_VISIBLE)

$oRDP.DesktopWidth = 800
$oRDP.DesktopHeight = 600
$oRDP.Fullscreen = False
$oRDP.ColorDepth = 16
$oRDP.AdvancedSettings3.SmartSizing = True
$oRDP.Server = $host
$oRDP.UserName = "" ; <--- Username
$oRDP.Domain = ""
$oRDP.AdvancedSettings2.ClearTextPassword = "" ; <--- Password
$oRDP.ConnectingText = "Connecting to " & $host
$oRDP.DisconnectedText = "Disconnected from " & $host
$oRDP.StartConnected = True
$oRDP.Connect()
$oShel = ObjCreate("shell.application")
$oShel_Ctrl = GUICtrlCreateObj($oShel, 64, 44, 800, 600)
GUICtrlSetStyle($oShel_Ctrl , $WS_VISIBLE)
GUISetState(@SW_SHOW, $hGUI)

Send ("#r") ; !!

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            $oRDP.Disconnect()
            Exit
    EndSwitch
WEnd

Now, I want to launch an application in the RDP session. I tried " Send(#r) " in order to send the path with a function like SendKeys but this command is execute on my computer and not on the remote computer.

How can I do please?

Andreas
  • 5,393
  • 9
  • 44
  • 53
user3797832
  • 7
  • 1
  • 8

2 Answers2

0

Send alt + home. This open the windows search in the rdp session, which you can then send it text e.g. send("notepad") send({enter})

Glen
  • 619
  • 4
  • 9
  • How can you do to focus on the rdp session ?? – user3797832 Jul 21 '14 at 06:34
  • Make the remote desktop connection window the active window and the rdp session will receive send commands, just start with alt home. – Glen Jul 21 '14 at 08:40
  • I can't do alt home because I don't have the focus on it.. alt home execute window search on my computer and not on the remonte desktop – user3797832 Jul 21 '14 at 09:06
  • This will specifically work for the "remote desktop connection" application. Use winactivate to give you focus and then send(!{home}). Not sure if it'll work in your case. – Glen Jul 21 '14 at 09:25
0

Update:

A much simpler alternative:

  • Change the Remote Desktop Connection Settings (not in the control code, but in the usual windows shorcut. But it seems that could be done in the AutoIt code with the keyboardhook setting keyboardhook setting ) .
  • Look for the Options button, in the window when launching remote desktop.
  • On the Local Resources Tab select Windows key combinations are applied in full-screen mode only.
  • Change this line in your code:

    $oRDP.Fullscreen = True

  • Include a pause to ensure the control has been loaded

    Sleep(5000)

    Send ("#r")

Previous answer:

Let my suggest a workaround not very 'elegant' but should work (tested ok):

In the remote desktop make a shorcut to the Windows Virtual Keyword (On-Screen Keyboard or OSK)

  • Find the position of the shorcut icon

  • In your code send a double click at this position to start the on-screen keyboard

  • Then send clicks to the positions of the desired keys

Something like this:

Sleep(5000)
MouseClick("left",512,191,2) ;start virtual keyword
Sleep(1000)
MouseClick("left",553,807,1) ;click
Sleep(100)
MouseClick("left",633,740,1)
Sleep(1000)
Send("notepad")
Sleep(1000)
Send("{ENTER}")

(Aside note: For any executable with a shortcut on the remote desktop simply send double click, without the need of the virtual keyboard)

robertocm
  • 124
  • 6