使用Java将焦点设置为Windows中的非Java应用程序 [英] Using Java to set the focus to a non Java application in Windows

查看:110
本文介绍了使用Java将焦点设置为Windows中的非Java应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想编写一个为Windows中的非Java应用程序创建输入的应用程序。使用Robot类可以很容易地生成输入,但是我需要将焦点设置到另一个应用程序的文本框并在那里输入文本。

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 focus to another application's text box and enter the text over there.

别担心我我不想写恶意的东西,我只是想用Java来扩展用Delphi编写的旧应用程序。

Don't worry I'm not trying to write something malicious, I just want to use Java to "extend" an old application written in Delphi.

推荐答案

CMDOW 是一个命令行实用程序,允许您执行各种窗口操作,如激活/停用,列表,最小化/最大化等。

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

或者,您可以编写VBScript来激活另一个应用程序。例如:

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

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

然后使用 Runtime.exec 来自你的Java应用程序来执行脚本。

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.

这篇关于使用Java将焦点设置为Windows中的非Java应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆