Java应用程序由Windows中的按键序列触发
是否可以“筛选”用户按下的每个键并搜索打开java程序的字符串?我希望创建一个有趣的应用程序,在检测到字符串“Open sesame”时触发程序中弹出一个窗口。这可以用java来完成吗?
编辑: 系统范围监听触发程序的字符串。我还想知道使用 win-api 挂钩是否适合于此。
Is it possible to "screen" every key pressed by the user and search for the string that opens the java program? I hope to create a fun application that upon detecting the string "Open sesame" to trigger a window in my program to pop-up. Can this be done with java?
EDIT:
The string that triggers the program is listened for system-wide. I'm also wondering wether the use of win-api hooks would be appropriate for this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
从技术上讲,您无法在 java 中执行此操作,因为 java 在虚拟机中运行,并且实际的键缓冲发生在 BIOS 级别(我的意思是填充键盘类型提前缓冲区)。您需要比 java 所能提供的更低级别的访问权限。可能有解决方法,但通常您不能使用具有托管代码的语言来执行此类操作。我已经用 C# 连接到了这些 api,所以也许用 java 也有可能,但为什么不直接用 c++/c 来做呢?
You can't technically do this in java as java runs in a virtual machine and the actual key buffering occurs at a bios level (filling the keyboard type ahead buffer i mean). You need lower level access than java can provide. There may be work arounds but in general you can't use a language with managed code to do this kind of thing. I have hooked into those api's with C# so maybe that is a possibility with java too but why not just do it in c++/c then.
我会研究关键侦听器。
I would look into a Key Listener.