我可以将另一个程序的窗口移动到焦点的前方吗? [英] Can I move another program's window to the front of focus?

查看:183
本文介绍了我可以将另一个程序的窗口移动到焦点的前方吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用它的API与第三方应用程序进行交互,并希望在用户执行某个操作时将其移动到焦点的前端(以便它位于所有其他打开的窗口之上)。虽然我可以很容易地在层次结构中上下移动我的应用程序,但似乎没有办法与其他窗口进行交互。是否可以使用Java将另一个程序的窗口移到前面?

I am interacting with a third party application using it's API, and would like to move it to the front of focus (so that it is on top of all other open windows) when a user performs a certain action. While I can move my application up and down in the hierarchy pretty easily, there doesn't appear to be a way to interact with other windows. Is it possible to move another program's window to front with Java?

推荐答案

您不能在纯Java代码中执行此操作,但是你可以使用JNI。参见在Java Swing中,如何获得对窗口的Win32窗口句柄(hwnd)引用?如何获取窗口句柄。然后你可以做一些像 http://msdn.microsoft.com/en-us/ library / ms633545 将它移到前面。

You can't do it in pure Java code, but you could using JNI. See In Java Swing how do you get a Win32 window handle (hwnd) reference to a window? for how to get a handle to the window. Then you could do something like http://msdn.microsoft.com/en-us/library/ms633545 to move it to the front.

警告:这只适用于Windows

Caveat: This is for windows only

这篇关于我可以将另一个程序的窗口移动到焦点的前方吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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