- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
mouse_event 函数将光标发送到稍有错误的坐标(偏离 1-20 像素)。它“关闭”的程度取决于我不太清楚的模式。
这是我的代码
int x, y;
int repeats = 1000;
int start = 0;
POINT pt;
for(int i=0; i<repeats; i+=10) //first loop, down right
{
x = (65536 / 1920) * i - 1; //convert to absolute coordinates
y = (65536 / 1080) * i - 1;
mouse_event(MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE, x, y, 0, 0); //move
GetCursorPos(&pt); //get cursor position
if(pt.x != i){mouse_event(MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE, x, y, 0, 0);} //check if the position is wrong, and if so fix it.
if(pt.y != i){mouse_event(MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE, x, y, 0, 0);}
cout << "Try: " << i << ", " << i << "\tReal: " << pt.x << ", " << pt.y << "\tDiff: " << pt.x - i << ", " << pt.y - i << '\n';
}
for(int i=repeats; i>0; i-=10) //second loop, up left
{
x = (65536 / 1920) * i - 1;
y = (65536 / 1080) * i - 1;
mouse_event(MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE, x, y, 0, 0);
GetCursorPos(&pt);
if(pt.x != i){mouse_event(MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE, x, y, 0, 0);}
if(pt.y != i){mouse_event(MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE, x, y, 0, 0);}
cout << "Try: " << i << ", " << i << "\tReal: " << pt.x << ", " << pt.y << "\tDiff: " << pt.x - i << ", " << pt.y - i << '\n';
}
如果运行它,它会导致鼠标从屏幕左上角向下和向右移动,然后再次向上移动。但它越往下走,“mouse_event”产生的鼠标移动就越不正确。
我移动它,然后记录当前坐标,然后计算差值。差异(运动误差)随着屏幕的向下移动而增加。我什至尝试添加一个额外的检查来测试坐标是否关闭,然后再次尝试将鼠标移动到正确的位置,但它不起作用
知道为什么会这样吗?
为方便起见,这里是该程序的输出日志。
它清楚地表明,在第一个循环(将鼠标向下和向右移动)中,错误增加了,然后在第二个循环(再次向上和向左移动)中,错误以相同的方式减少。
知道为什么会这样吗?它也以我无法量化的方式发生在更复杂的实现上,并且与此不同,所以我认为它必须在 mouse_event 函数本身或某些我不理解的功能中
在此先感谢您的帮助
最佳答案
我会说这是由于使用整数算术来计算像素,试试这个:
x = (int)(65536.0 / 1920 * i - 1); //convert to absolute coordinates
y = (int)(65536.0 / 1080 * i - 1);
关于c++ - "mouse_event"函数 - 将光标发送到(稍微)错误的坐标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16849523/
我有一个可视化 C# 项目,我想从中编译两个可执行文件:Full.exe 和 Limited.exe。 Limited.exe 只是隐藏了几个 UI 控件。 我正在考虑添加另一对解决方案配置(Debu
我和我的伙伴正计划将我们拥有的 python 应用程序移植到 iOS。我们使用 numpy 的 SVD、范数和 pinv功能,我不知道如何转换为 iOS。我查看了 Accelerate文档,没有看到任
即,它永远不会使用某些特定的 upperBound 参数连续生成超过 16 个偶数: Random random = new Random(); int c = 0; int max = 17; in
我的问题是我必须使用第三方函数/算法,它采用 double 数组作为输入,但显然对输入数据中的非常小的变化很敏感.但是对于我的应用程序,我必须为(几乎)相同的输入获得相同的结果!特别是我有两个测试输入
mouse_event 函数将光标发送到稍有错误的坐标(偏离 1-20 像素)。它“关闭”的程度取决于我不太清楚的模式。 这是我的代码 int x, y; int repeats = 1000; in
在 C++ 类(class)中,我学到了避免重复计算、使用更多加法而不是更多乘法、避免幂等技巧来提高性能。然而,当我尝试让他们用 Julia-Lang 优化代码时,我对相反的结果感到惊讶。 例如,这里
好的。请耐心听我说,我不擅长解释事情。 我有一个通过网站上的表格收集的联系信息数据库。显然,人们不小心(或故意,但修复是一个不同的问题)多次按下“提交”,因此该数据库中有很多重复的行。 因此,tabl
我一直在用各种语言和实现实现相同的代码(在 Blackjack 中发牌而不爆牌的方法的数量)。我注意到的一个奇怪之处是,Python 在 C 中调用分区函数的实现实际上比用 C 编写的整个程序快一点。
我在使用 Pandas 解析数据的时间戳时遇到问题。 我尝试解析的日期时间格式示例类似于 2012-05-02 01:00:00-05:00。从 Pandas 文档中,我被驱动到相关的 Python
下面函数模板的目标是取任意unordered_map并产生一个新的unordered_map与 key_type和 mapped_type倒。下面的函数适用于 std::unorderd_map .我
我是一名优秀的程序员,十分优秀!