当前位置: 首页 > 编程语言 > C#

模拟鼠标移动分享

时间:2023-04-10 18:25:44 C#

模拟鼠标移动我的UserControl中有ListView和images。当我把鼠标移开图片图片时,我拍的图片就是重绘后的图片。但是当我对同一张照片进行第二次拍摄时,我并不想重新绘制,而是当我拿掉ListView的教堂并再次使用navozhu时。我以为我可以做一只仿老鼠。或者告诉我一些更好的。[DllImport("user32.dll")]staticexternboolSetCursorPos(intX,intY);它有效,但我看到了鼠标的痕迹。为了模拟鼠标移动、按钮点击等,可以尝试使用mouse_eventAPI函数。注意,它适用于米奇而不是像素:http://msdn.microsoft.com/en-us/library/windows/desktop/ms646260(v=vs.85).aspx以上是C#学习教程:模拟鼠标运动分享如果对你有用,需要了解更多C#学习教程,希望大家多多关注—[DllImport("User32.dll",EntryPoint="mouse_event",CallingConvention=CallingConvention.Winapi)]internalstaticexternvoidMouse_Event(intdwFlags,intdx,intdy,intdwData,intdwExtraInfo);[DllImport("User32.dll",EntryPoint="GetSystemMetrics",CallingConvention=CallingConvention.Winapi)]internalstaticexternintInternalGetSystemMetrics(intvalue);...//将鼠标光标移动到绝对位置to_x,to_y并单击鼠标左键:intto_x=500;intto_y=300;intscreenWidth=InternalGetSystemMetrics(0);intscreenHeight=InternalGetSystemMetrics(1);//米奇X坐标intmic_x=(int)System.Math.Round(to_x*65536.0/screenWidth);//米奇Y坐标intmic_y=(int)System.Math.Round(to_y*65536.0/screenHeight);//0x0001|0x8000:移动+绝对位置Mouse_Event(0x0001|0x8000,mic_x,mic_y,0,0);//0x0002:左键按下Mouse_Event(0x0002,mic_x,mic_y,0,0);//0x0004:左键向上Mouse_Event(0x0004,mic,mic_y,0,0);本文收集自网络,不代表立场。如涉及侵权,请点击右侧联系管理员删除。如有转载请注明出处: