无法使用自动IT脚本连接到远程桌面

时间:2018-10-29 06:44:29

标签: java autoit remote-desktop

请帮助,使用Java连接到远程桌面时,显示“登录尝试失败”,但手动可以连接。

我正在使用AutoItX类,对象

下面是我尝试连接的代码:

@Test
public void openRunWindow() throws AWTException {

    object.robotkeyPress(KeyEvent.VK_WINDOWS);
    object.robotkeyPress(KeyEvent.VK_R);
    object.autoitWinWaitActivate("Run");
    System.out.println("Run window is open");
    object.robotkeyRelease(KeyEvent.VK_R);
    object.robotkeyRelease(KeyEvent.VK_WINDOWS);
    object.autoitSendKeys("mstsc");
    System.out.println("Mstsc is entered");
    object.robotkeyPress(KeyEvent.VK_ENTER);
    object.autoitWinWaitActivate("Remote Desktop Connection");
    System.out.println("Remote Desktop Connection window is open");
    object.robotkeyRelease(KeyEvent.VK_ENTER);
    object.autoitSendKeys("ipaddress");
    System.out.println("Remote Desktop Connection - Ip address is entered");
    object.robotkeyPress(KeyEvent.VK_ENTER);
    object.robotkeyRelease(KeyEvent.VK_ENTER);
    object.autoit.winWaitActive("Windows Security");
    System.out.println("Windows Security is open");
    // Enter Password
    object.autoitSendKeys("password");
    object.robotkeyPress(KeyEvent.VK_ENTER);
    object.robotkeyRelease(KeyEvent.VK_ENTER);

    // Press Enter on More Choices link
    try {
    Thread.sleep(3000);
    } catch (InterruptedException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }

}

0 个答案:

没有答案