用Java(OSX)设置任何应用程序的焦点? [英] Set focus of any application with Java (OSX)?

查看:189
本文介绍了用Java(OSX)设置任何应用程序的焦点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



如何在OSX上设置任意应用程序(Java或不是Java)的焦点(例如cmd + tab)回答这个问题,我碰到这个问题,但它并没有帮助OSX。



编辑:一个可能性似乎是使用像 Quicksilver Robot 用修饰符发送按键。我喜欢更便携的东西,但是,编译后需要更少的设置才能进行更改.... 应该能够使用

 <$ c $> $ 打开 命令c> Runtime.exec(open /path/to/Whichever.app); 

(或者是该函数的一些等效的重载。)如果还没有运行,这也会打开一个应用程序。


How can I set the focus (e.g. cmd+tab) of an arbitrary application (Java or not) from a Java program, on OSX?

Looking for an answer to this question, I came across this question, but it doesn't really help for OSX.

EDIT: one possibiltiy seems to be to use something like Quicksilver, and a Robot to send it keypresses with modifiers. I'd prefer something more portable, though, that requires less setup to make changes after it's compiled....

解决方案

You should be able to reactivate an already running app using the open command that comes with OS X:

Runtime.exec("open /path/to/Whichever.app");

(Or some equivalent overload of that function.) This will also open an app if it's not running yet.

这篇关于用Java(OSX)设置任何应用程序的焦点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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