笔记本电脑触摸板编程
我想编写一个程序,可以根据我在触摸板上移动手指的方式来控制光标移动。我希望我的程序获取用户触摸触摸板的位置,然后我想使用我自己的程序控制鼠标移动。我想用 Java 来做这个。我可以用 Java 来做这个吗?我想在 Windows 操作系统上运行它。我的笔记本电脑触摸板设备驱动程序是否提供一些 API,我可以通过这些 API 获取有关用户何时何地触摸触摸板的信息?
I want to write a program which can control my cursor movements depending on the the way I move my finger on the touchpad. I want my program to get the location where the user touched the touchpad, then I want to control mouse movement using my own program. I want do this in Java. Can I do this in Java? I would like to run it on Windows OS. Does my laptops touchpad device driver provide some API by which I can get the info about when and where the user touched the touchpad?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
想想这种情况。
有人想要退出你的程序。他们触摸触控板。你的程序将光标移动到他们没有预料到的地方。他们感到不安和困惑。
他们继续触摸触控板,您的程序继续执行他们没有预料到的事情。他们发现自己无法控制光标。现在怎么办?
一般来说,让程序移动光标会导致灾难。
光标很难在屏幕上找到。对对话框进行“光标变形”的 X-windows 应用程序有一个选项可以禁用此功能,因为它很混乱。
取消用户对光标的控制会使计算机(已经很难使用)变得更难使用,因为有这种“模式”的东西。当你的程序运行时,会发生一件事。当你的程序没有运行时,会发生一些不同的情况。
查看 http://java.sun。 com/j2se/1.4.2/docs/api/java/awt/Cursor.html
似乎没有任何方法可以更改光标的位置。它跟踪鼠标。
但是,请查看 http://java.lang. sun.com/j2se/1.5.0/docs/api/java/awt/Robot.html
它具有合成鼠标事件的能力。随意玩吧。
Think about this situation.
Person wants to exit your program. They touch the trackpad. Your program moves the cursor somewhere they didn't expect. They're upset and confused.
They continue to touch the trackpad, your program continues to do something they didn't expect. They find they're unable to control the cursor. Now what?
Generally, having your program move the cursor is a recipe for disaster.
The cursor is hard enough to spot on the screen. X-windows applications which do "cursor warping" to dialog boxes have an option to disable this because it is confusing.
Removing control of the cursor from the user makes the computer (already very hard to use) much harder to use because there's this "mode" thing. When your program is running, one thing happens. When your program is not running, something different happens.
Look at http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Cursor.html
There do not appear to be any methods to change the cursor's position. It tracks the mouse.
However, look at http://java.sun.com/j2se/1.5.0/docs/api/java/awt/Robot.html
This has the ability to synthesize mouse events. Feel free to play with it.