简体   繁体   English

鼠标单击屏幕上任何文本框上的Java侦听器

[英]Java listener for mouse click on any textbox on the screen

Is there a way for Java to listen to another program for mouse clicks? Java是否可以通过一种方法来监听其他程序以进行鼠标单击?

If so, is there a way to listen for mouse clicks on text inputs on other programs? 如果是这样,是否有一种方法可以监听其他程序上文本输入的鼠标单击?

I'm making an on screen keyboard for a project I'm working on. 我正在为正在进行的项目制作屏幕键盘。 It will automatically be displayed when the user selects any text input on the screen. 当用户在屏幕上选择任何文本输入时,它将自动显示。 When the text input is unfocused, the keyboard would disappear. 当文本输入未聚焦时,键盘将消失。

Strictly speaking, in Java there is no way to detect Mouse or Keyboard events when your application is not in focus. 严格来说,在Java中,当您的应用程序不集中时,无法检测到Mouse或Keyboard事件。 This is a security mechanism that is built into Java. 这是Java内置的安全机制。

An application cannot listen for these events unless it has root (admin) privileges anyway. 除非它始终具有root(管理员)特权,否则应用程序无法侦听这些事件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM