AutoIt:发送消息/键到GUICtrl(远程桌面)

时间:2014-07-09 08:28:44

标签: user-interface desktop send autoit

我想使用autoIT向GUICtrl发送命令(windows + r)。当我发送时("#r")它可以在我的计算机上工作,而不是在远程桌面上。我想在RDP会话中这样做。有人可以帮帮我吗?拜托!

代码:

$host = "" ;<<<<<<< enter here the host name or ip address
$hGUI = GUICreate("Terminal server", 900, 700, -1, -1, $WS_OVERLAPPEDWINDOW + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN)
$oRDP = ObjCreate("MsTscAx.MsTscAx.2")
$oRDP_Ctrl = GUICtrlCreateObj($oRDP, 0, 0, 900, 700)
GUICtrlSetResizing(-1, $GUI_DOCKALL)
GUICtrlSetStyle($oRDP_Ctrl , $WS_VISIBLE)
$oRDP.DesktopWidth = 900
$oRDP.DesktopHeight = 700
$oRDP.Fullscreen = False
$oRDP.ColorDepth = 16
$oRDP.AdvancedSettings3.SmartSizing = True
$oRDP.Server = $host
$oRDP.UserName = "" ;<<<<<<< enter here the user name
$oRDP.Domain = ""
$oRDP.AdvancedSettings2.ClearTextPassword = ""
$oRDP.ConnectingText = "Connecting to " & $host
$oRDP.DisconnectedText = "Disconnected from " & $host
$oRDP.StartConnected = True
$oRDP.Connect()

GUISetState(@SW_SHOW, $hGUI)


$oShel = ObjCreate("shell.application")
$oShel_Ctrl = GUICtrlCreateObj($oShel, 0, 0, 900, 700)
GUICtrlSetStyle($oShel_Ctrl , $WS_VISIBLE)


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

2 个答案:

答案 0 :(得分:0)

通过RDP连接时,您将需要使用特殊快捷键。您可以在此处找到一个列表:Remove Desktop Services Shortcut Keys

尝试发送ALT + HOME:

Send("{ALT}{HOME}")

答案 1 :(得分:0)

我找到了解决方案。我使用PsExec.exe,它更容易!

PS :选项后不要忘记会话的ID。如果没有它,PsExec将可以工作,但只能在流程中工作,不会成为窗口