java.awt.Robot中的鼠标preSS是没有任何影响 [英] Java.awt.robot mousepress is not having any effect
问题描述
我试图模拟使用awt.robot不同的程序左击,具有以下code:
I'm trying to simulate a left click in a different program using awt.robot, with the following code:
int mask = InputEvent.BUTTON1_DOWN_MASK;
bot.mouseMove(x, y);
bot.mousePress(mask);
bot.mouseRelease(mask);
虽然这是移动鼠标到屏幕的正确部分,其他程序似乎没有被接收到点击。我在做什么错了?
While this is moving the mouse to the correct part of the screen, the other program doesn't seem to be receiving the click. What am I doing wrong?
在某些其他方案,这种相同的方法生产的点击,但在一个程序,它没有任何效果。
In certain other programs, this same method produces the click, but in one program, it has no effect.
我曾尝试视频下载()
等待的mouseMove和鼠标preSS之间30-300毫秒,但是它没有任何效果。
I have tried Thread.sleep()
to wait 30-300 milliseconds between mouseMove and mousePress, but it had no effect.
我是否需要使用JNI和本机Windows API来实现这一目标?我在Windows 8上。
Do I need to use JNI and native windows API to achieve this? I'm on Windows 8.
推荐答案
您使用了错误的面具: InputEvent.BUTTON1_MASK
You are using the wrong mask: InputEvent.BUTTON1_MASK
这篇关于java.awt.Robot中的鼠标preSS是没有任何影响的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!