怎么用Windows API模拟鼠标移动事件?

怎么用Windows API模拟鼠标移动事件


慕盖茨4494581
浏览 3456回答 4
4回答

眼眸繁星

具体代码如下:PutAttachment "d:\p", "*.*"//获取窗口句柄Hwnd = Plugin.Window.MousePoint()//获取窗口客户区左上角坐标sRect = Plugin.Window.GetClientRect(Hwnd)xyArray = Split(sRect, "|", - 1 , 1)dx = xyArray(0)dy = xyArray(1)//转移窗口KMData = Plugin.bgkms6_10.KMTransform(hwnd, 0)//Plugin.BGCP2_02.TransformWindow 参数1//加载图片tu = Plugin.BGCP2_02.LoadBMP("d:\p\4.bmp")tu1 = Plugin.BGCP2_02.LoadBMP("d:\p\12.bmp")DoCall Plugin.Bkgnd.KeyPress(Hwnd, 9)Delay 100Call Plugin.Bkgnd.KeyPress(Hwnd, 49)Delay 3000For 60Call Plugin.BGCP2_02.FindPicture(hwnd, 0, 0, 1024, 768 ,tu(0), 30, 0.9, ipX, ipY)If ipX > 0 And ipY > 0 ThenCall Plugin.Bkgnd.KeyPress(Hwnd, 51)Delay 1000Call Plugin.BGCP2_02.FindPicture(hwnd, 0, 0, 1024, 768 ,tu1(0), 30, 0.9, intX, intY)If intX > 0 And intY > 0 ThenCall Plugin.bgkms6_10.MoveTo(KMData, intX, intY) //Delay 1000call Plugin.bgkms6_10.LeftClick (KMData) //这里后台点击鼠标左击没反应Delay 200End IfEnd If//End IfNextDelay 100LoopSub OnScriptExit//释放转移窗口Call Plugin.BGCP2_02.UnTransformWindow(Hwnd)call Plugin.bgkms6_10.KMUntransform (KMData)End Sub

临摹微笑

在我们自定义窗体的时候,实现鼠标点击拖动标题栏移动窗体是必要的,而用Windows API来实现这一功能相对来说最简单,需要用到的API函数有两个:1:BOOL WINAPI ReleaseCapture(void);2:LRESULT SendMessage(HWND hWnd,UINT Msg,WPARAM wParam,LPARAM IParam)

摇曳的蔷薇

没有区别,因为windows系统和C++api的底层函数库是共享的,因此对于鼠标所引发的事件其处理机制是一致的。
打开App,查看更多内容
随时随地看视频慕课网APP