Manipulating windows from other applications in Java

孤者浪人 提交于 2020-01-06 02:21:09

问题


I want to write a Windows 7 Window Manager in Java, but there are some issues. First of all, how do i manipulate the size and position of a window that doesn't belong to my own application? In other words, how can I manipulate the windows of other applications?

And, related to my first question, is it possible to get a list of all current windows?

And, the last question: is Java suited for this task or should I take a look at C#?


回答1:


First: Java is probably not the best suited language for this task. You need to call the native Windows API, so C/C++ would be a natural fit. You can use Java with JNI, but is probably not worth the hassle. I dont know about C#/Managed C++, so cant say something about it.

Getting a List of current Windows: http://support.microsoft.com/kb/183009

Changing Window Positions:
SetWindowPos
SetWindowPlacement

You may also need to get informed whenever a window changes. Look at e.g. SetWindowsHookEx, especially the CBTHook.

Edit: Last Time i tried, it was always allowed to change windows of other processes. If this isnt allowed anymore under windows7, you can always install a global hook and change the windows from INSIDE the process...



来源:https://stackoverflow.com/questions/3386801/manipulating-windows-from-other-applications-in-java

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!