我試圖仿效在Win7各種任務回車鍵和我有一些問題,這個功能:仿效鍵盤在C#
LeftMouseClick(Cursor.Position.X - 720, Cursor.Position.Y - 45);
System.Threading.Thread.Sleep(1000);
// Simulate each key stroke
InputSimulator.SimulateKeyDown(VirtualKeyCode.RETURN);
InputSimulator.SimulateKeyUp(VirtualKeyCode.RETURN);
InputSimulator.SimulateTextEntry("cmd");
System.Threading.Thread.Sleep(1000);
InputSimulator.SimulateKeyDown(VirtualKeyCode.RETURN);
InputSimulator.SimulateKeyUp(VirtualKeyCode.RETURN);
所有我想要做的就是按START,寫CMD,然後回車。除了按下回車鍵之外,所有的工作都很順利。
所有這一切都在一個RDP的ActiveX發生,這裏是代碼:
var client = (IMsRdpClient7)rdp.GetOcx();
// client.RemoteProgram2.RemoteProgramMode = true;
((MSTSCLib.IMsRdpClientAdvancedSettings5)rdp.AdvancedSettings).DisplayConnectionBar = true;
((MSTSCLib.IMsRdpClientAdvancedSettings5)rdp.AdvancedSettings).ConnectionBarShowPinButton = true;
((MSTSCLib.IMsRdpClientAdvancedSettings5)rdp.AdvancedSettings).BitmapVirtualCache32BppSize = 48;
((MSTSCLib.IMsRdpClientAdvancedSettings5)rdp.AdvancedSettings).ConnectionBarShowRestoreButton = false;
((MSTSCLib.IMsRdpClientAdvancedSettings5)rdp.AdvancedSettings).ConnectionBarShowMinimizeButton = true;
((MSTSCLib.IMsRdpClientAdvancedSettings5)rdp.AdvancedSettings).EnableWindowsKey = 1;
((MSTSCLib.IMsRdpClientAdvancedSettings5)rdp.AdvancedSettings).GrabFocusOnConnect = true;
((MSTSCLib.IMsRdpClientAdvancedSettings5)rdp.AdvancedSettings).RedirectDrives = true;
((MSTSCLib.IMsRdpClientAdvancedSettings5)rdp.AdvancedSettings).RedirectClipboard = true;
((MSTSCLib.IMsRdpClientAdvancedSettings5)rdp.AdvancedSettings).RedirectPrinters = true;
((MSTSCLib.IMsRdpClientAdvancedSettings5)rdp.AdvancedSettings).RedirectPOSDevices = true;
rdp.Server = "1.2.3.4";
rdp.UserName = "Rmlabuser2";
IMsTscNonScriptable secured = (IMsTscNonScriptable)rdp.GetOcx();
secured.ClearTextPassword = "Rmlabuser2";
// rdp.FullScreenTitle = "Full Screen";
// rdp.SecuredSettings.FullScreen = 1;
// rdp.SecuredSettings.StartProgram = "calc";
rdp.Connect();
我再說一遍,鑰匙的作品,我打不進去。
謝謝。
你試過SendKeys.Send( 「{} ENTER」); ?我發現它在這裏,如果有幫助:https://msdn.microsoft.com/en-us/library/ms171548(v=vs.110).aspx –
給我打破錯誤,我只能使用SendKeys.SendWait ...並且它只是在等待,我發現輸入命令被髮送,腳本結束後我立即ALT + TAB,並且看到進入,但不在該ActiveX RDP面板中...任何ideea? – Damian
也許這可能是什麼? https://msdn.microsoft.com/en-us/library/windows/desktop/aa381294(v=vs.85).aspx –