开发者

Windows programming in Java? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 11 years ago.

What is a easy to learn framework or technique for windows-programming (calling win32 api) in Java?

I need to be able to access the windows api to do things such as send keystrokes,开发者_如何学运维 open applications, restart windows, etc.


The easiest for me has been to make small utility programs with AutoIt version 3 and then have my Java programs call these utility programs. The programs can communicate via input and output streams. If I want to delve deeper into windows, JNA is the way to go and there are lots of examples on how to use this here and at its site. JNI is another way (JNA uses JNI actually), but I find it more difficult as my C is quite rusty.

Edit:
Many folks have suggested using a Robot object, but the problem I have had with using Robot is that you can't enumerate the non-Java windows and then activate the desired window through Java alone. Also, you can't interact directly with window controls as you can with JNA and with AutoIt.


For send keystrokes, you can use java java.awt.Robot, and for open application, java.lang.ProcessBuilder is there. There API are os independent.

And for restart windows, maybe also use ProcessBuilder to call "shutdown" command, see here. Shutdown Windows with Java

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜