Using Java to set the focus to a non Java application in Windows

前端 未结 5 639
一整个雨季
一整个雨季 2020-12-06 09:56

I would like to write an application who creates input for a non-Java application in Windows. With the Robot class it\'s easy to generate the input, but I need to set the fo

5条回答
  •  再見小時候
    2020-12-06 10:42

    CMDOW is a command line utility which allows you to perform various window actions such as activating/deactivating, listing, minimising/maximising etc.

    Alternatively, you can write a VBScript to activate another application. For example:

    Set WshShell = WScript.CreateObject("WScript.Shell") 
    WshShell.AppActivate("Firefox")
    

    Then use Runtime.exec from your Java app to execute the script.

    This will help you activate another application.

    However, it will be much more difficult if you want to focus on a textbox within the other application and write some text.

提交回复
热议问题