在 Java 中从其他应用程序操作窗口
我想用Java编写一个Windows 7窗口管理器,但有一些问题。首先,如何操作不属于我自己的应用程序的窗口的大小和位置?换句话说,我如何操作其他应用程序的窗口?
而且,与我的第一个问题相关的是,是否可以获得所有当前窗口的列表?
最后一个问题:Java 适合这项任务还是我应该看看 C#?
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#?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
第一:Java 可能不是最适合此任务的语言。您需要调用本机 Windows API,因此 C/C++ 是一个自然的选择。您可以将 Java 与 JNI 结合使用,但可能不值得这么麻烦。我不了解 C#/托管 C++,所以不能说些什么。
获取当前 Windows 列表:
http://support.microsoft.com/kb/183009
更改窗口位置:
设置窗口位置
SetWindowPlacement
您可能还需要在窗口更改时获得通知。看看SetWindowsHookEx,尤其是CBTHook。
编辑:上次我尝试时,总是允许更改其他进程的窗口。如果在 windows7 下不再允许这样做,您可以随时安装全局挂钩并从进程内部更改窗口...
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...