简体   繁体   English

在Linux / X Window System下阅读屏幕/单击鼠标?

[英]Screen reading / mouse clicking under Linux / X Window System?

I'm learning about AI and (just for fun and practice, not profit or anything evil) I'd like to write a little bot to play a rinky-dink Flash game for me. 我正在学习AI,并且(只是为了娱乐和练习,而不是牟取暴利或其他邪恶的东西),我想写一个小机器人来为我玩一个溜溜的Flash游戏。

As a Microsoft hater, I'm embarrassed to say that I know and have used the required function calls some time ago under Windows, programming in Delphi. 作为Microsoft的仇恨者,我很尴尬地说我早在Windows下在Delphi中编程时就已经知道并使用了必需的函数调用。 But these days I try to do everything under Linux and I don't seem to have any idea. 但是这些天我尝试在Linux下做所有事情,但似乎没有任何想法。

Requirements: 要求:

  • to grab part of the screen's contents in image or bitmap form, periodically or on programmatic request; 定期或根据程序要求获取图像或位图形式的屏幕内容的一部分;
  • to simulate mouse pointer moves and left clicks under programmatic control; 在程序控制下模拟鼠标指针的移动和左键单击;
  • keyboard grabbing might come in handy too. 键盘抓取也可能派上用场。

Ideally, I'd like to do this from a Clojure application running in the JVM, so a Java compatible library would be the cat's meow. 理想情况下,我想从JVM中运行的Clojure应用程序中执行此操作,因此Java兼容的库将是您的最佳选择。 But failing that, I could write myself a C program to mediate between X Window and my app via local TCP/IP. 否则,我可以编写一个C程序来通过本地TCP / IP在X Window和我的应用程序之间进行中介。

You can always rely upon the good old java.awt.Robot class, which, i think, has all the features you're asking : 您总是可以依赖旧的java.awt.Robot类,我认为它具有您要求的所有功能:

  • moving mouse 移动鼠标
  • capturing a Rectangle on screen 在屏幕上捕获矩形
  • clicking mouse 点击鼠标

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

相关问题 如何在Linux的X Window System中找到一个窗口并将其置于最前面? - How to find a window in X Window System on Linux and bring it to front? linux下不同用户下的java系统偏好设置 - java system preferences under different users in linux 用鼠标单击某个对象后如何在屏幕上打印某些内容? - How to print something on the screen after clicking with a mouse on some object? 当鼠标位于 JLabel 下方时出现黄色窗口 -> 如何移除? - Yellow Window under JLabel when the mouse is above it -> how to remove? 单击返回按钮重定向到android设备中的主窗口/屏幕 - redirect to main window/screen in android device on clicking the back button 鼠标单击时鼠标指针下方的精灵坐标偏移补偿问题 - Mouse coordinates offset compensation issue for sprite under pointer on left-clicking 在 Windows、Linux 下可见访问器方法,但在 OS X 下不可见 - Accessor method visible under Windows, Linux, but not OS X Java鼠标单击问题 - Java Mouse Clicking Issue 在JMETER CMD控制台窗口中-在使用侦听器以外的鼠标滚动在“线程组”下添加组件时出现问题 - In JMETER CMD console window-Issue on while Adding Components under Threadgroup using mouse scrolling except Listeners 检查鼠标下的组件 - Check component under mouse
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM