开发者

How do I programmatically resize and change position of a window

How to resize (and change the position) of a window of other application programmatically? I would like to code with Java, and I wan开发者_StackOverflowt to resize all windows, not only those which are created by JVM. I'm using Windows XP. I would like to change other properties of those windows if there are more options.

Additional information after comments:

Q: Why do you want to do that? A: Windows lacks feature to move window across multiple displays fast. Have you tried WinSplit Revolution 9.02? It has some great features move/position window with just few button presses. You don't need to grab a mouse at all.


The only way to do anything with windows who are not your own in pure java would be the java.awt.Robot class. But it also does not offer any useful API for your goal, so you only could do a screenshot, analize the results, and then position, press, move and release the mouse accordingly - thus, do the same as a human user would do.

If you want more, your would have to get system-specific. I think both the Windows API and the X protocol (ant thus the X client libraries) offer at least the ability to get informations about other program windows, I don't know about changing them. (I suppose Mac OS has such capabilities, too.)

This usually would mean writing at least the basics of this functionality in C (or any other language which access to such a library) and then use JNI to access this from Java. You could also use a JNI-wrapping library like JNA (Java Native access) to leave out the JNI step.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜