简体   繁体   中英

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

I want to be able to open Mozilla Firefox in a Remote Desktop and be able to "play" inside Mozilla (accessing URLs, import from the "Desktop" of the Remote Desktop Connection). All these, I want them to be automatically executed. That is why I have created a java code in eclipse. So far, I am able to automatically access the Remote Desktop Connection. Please find the code that I am using for this:

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");
}

Could you assist me on how I will be able to open Mozilla in Remote Desktop through eclispse?

Thank you in advance!

I assume the code successfully activates the RDP Window.

Once it is active AutoIt can't identify elements controls inside the window, but you can still send keyboard commands using Java Robot or even AutoIt.

To launch Firefox send a Window+R and then pass the path of firefox.exe ("C:\\Program Files\\Mozilla Firefox\\firefox.exe") and send ENTER.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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