繁体   English   中英

如何使用eclipse中编写的Java代码在远程桌面中导航(例如,打开Mozilla)?

[英]How can i navigate (e.g. open Mozilla) in a Remote Desktop by using java code written in eclipse?

我希望能够在远程桌面中打开Mozilla Firefox,并能够在Mozilla中“播放”(访问URL,从远程桌面连接的“桌面”导入)。 所有这些,我希望它们能够自动执行。 这就是为什么我在eclipse中创建了Java代码的原因。 到目前为止,我已经能够自动访问远程桌面连接。 请找到我为此使用的代码:

public static void main(String[] args) throws IOException, InterruptedException {

    String ip = "xxx.xxx.xx.xx";    //check if this is the desired IP
    String userName = "XXX";        //check if this is the correct username
    String password = "XXXxxx";     //check if the password has changed
    String jacobDllVersionToUse;
    jacobDllVersionToUse = "jacob-1.18-x64.dll";

    File file = new File("lib", jacobDllVersionToUse);
    System.setProperty(LibraryLoader.JACOB_DLL_PATH, file.getAbsolutePath());

    // creating credentials
     Process p = Runtime.getRuntime().exec("cmdkey /generic:"+ip+" /user:"+userName+" /pass:"+password );
     p.destroy();    

     Process p2 = Runtime.getRuntime().exec("mstsc /v: "+ip+" /f /console");

     AutoItX x = new AutoItX();      
     x.winWaitActive("Remote Desktop Connection");
     x.controlClick("Remote Desktop Connection", "Co&nnect", "1");
     x.winWaitActive("Remote Desktop Connection");
     x.controlClick("Remote Desktop Connection", "Co&nnect", "1");
}

您能协助我如何通过eclispse在远程桌面中打开Mozilla吗?

先感谢您!

我假设代码成功激活了RDP窗口。

一旦激活,AutoIt将无法识别窗口中的元素控件,但是您仍然可以使用Java Robot甚至AutoIt发送键盘命令。

要启动Firefox,请发送Window + R,然后传递firefox.exe的路径(“ C:\\ Program Files \\ Mozilla Firefox \\ firefox.exe”)并发送ENTER。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM