编程将鼠标定位到某处,有的时候,鼠标像是有“惯性”似的总是“走过头”!!我用如下代码,反复定位,勉强能准确定位 /// <summary>
/// 用负反馈技术使鼠标准确的移动到指定位置
/// </summary>
/// <param name="p">到指定位置</param>
/// <returns></returns>
public static int FfkMouseMoveTo(Point p, byte MouseKeyName, MouseMoveToDelegate pMMouseMoveTo)
{
int result = 0;
int intcalc = 0;
Point getpont = new Point(0, 0);
if (p.X != -1)
{
while (p != getpont)
{
intcalc++;
Utils.DelayMilliseconds(500);
//LkfWin32API.SetCursorPos(p.X, p.Y);
result = pMMouseMoveTo(MouseKeyName, p.X, p.Y);// LkfUsbAPI.MMouseMoveTo(UsbMKutils.ConvertMouseKeyNameToAsciiCode(MouseKeyName.up.ToString()), p.X, p.Y);
Utils.DelayMilliseconds(500);
getpont = LkfWin32API.LkfGetCursorPos();
if (intcalc > 30)
{
throw new Exception("鼠标无法准确定位");
}
}
}
return result;
}
我会一点c#。以前用过按键精灵,好像也有这个问题,最严重的的时候反复定位30次也无法准确定位!!
/// 用负反馈技术使鼠标准确的移动到指定位置
/// </summary>
/// <param name="p">到指定位置</param>
/// <returns></returns>
public static int FfkMouseMoveTo(Point p, byte MouseKeyName, MouseMoveToDelegate pMMouseMoveTo)
{
int result = 0;
int intcalc = 0;
Point getpont = new Point(0, 0);
if (p.X != -1)
{
while (p != getpont)
{
intcalc++;
Utils.DelayMilliseconds(500);
//LkfWin32API.SetCursorPos(p.X, p.Y);
result = pMMouseMoveTo(MouseKeyName, p.X, p.Y);// LkfUsbAPI.MMouseMoveTo(UsbMKutils.ConvertMouseKeyNameToAsciiCode(MouseKeyName.up.ToString()), p.X, p.Y);
Utils.DelayMilliseconds(500);
getpont = LkfWin32API.LkfGetCursorPos();
if (intcalc > 30)
{
throw new Exception("鼠标无法准确定位");
}
}
}
return result;
}
我会一点c#。以前用过按键精灵,好像也有这个问题,最严重的的时候反复定位30次也无法准确定位!!
解决方案 »
- .net 把json格式的字符串转换成json类的
- 求懂使用C#开发三维图形的高手帮忙!!!!
- 16进制字符串转int出错的问题
- Excel的高级操作,求
- !大侠们, 在需要理解别人代码的时候, 你们使用什么方法? 借助什么工具呢?
- 位置居中
- 求救!用HtmlElement来模拟单击事件后,页面不跳转??
- 救命啊,c# image 的ImageUrl中文路径问题。HttpUtility.UrlEncode和Server.UrlEncode都试过了,还是无法显示。
- 请问怎样通过C#来修改注册表?
- 错误CS1501怎样处理?
- 学习看板制作
- C#编写的ActiveX控件通过网页传递参数, 操作html页面 给页面元素赋值 赋值成功, 怎么可以勾选复选框
所以永远不会相等,可能需要先进行坐标系转换再定位