EVENT_MOUSE_POINTER_MOVE的简单介绍
mouse_event MOUSEEVENTF_MOVE Or MOUSEEVENTF_ABSOLUTE, kX * 65559 / 1024, kY * 65559 / 768, 0&, 0&
65559是VB中规定的鼠标坐标的范围.而1027*768是指我们电脑实际的大小`这样的一个比例`就把原来VB对应的坐标`转换成了我们电脑屏幕中的坐标.
C#用mouse_event模拟鼠标点击的问题
1、首先添加using System.Runtime.InteropServices;
2、为鼠标添加模拟点击的各种参数
//鼠标事件??因为我用的不多,所以其他参数没有写
???private?readonly?int?MOUSEEVENTF_LEFTDOWN?=?0x0002;//模拟鼠标移动
???private?readonly?int?MOUSEEVENTF_MOVE?=?0x0001;//模拟鼠标左键按下
???private?readonly?int?MOUSEEVENTF_LEFTUP?=?0x0004;//模拟鼠标左键抬起
???private?readonly?int?MOUSEEVENTF_ABSOLUTE?=?0x8000;//鼠标绝对位置
???private?readonlyint?MOUSEEVENTF_RIGHTDOWN?=?0x0008;?//模拟鼠标右键按下?
???private?readonlyint?MOUSEEVENTF_RIGHTUP?=?0x0010;?//模拟鼠标右键抬起?
???private?readonlyint?MOUSEEVENTF_MIDDLEDOWN?=?0x0020;?//模拟鼠标中键按下?
???private?readonlyint?MOUSEEVENTF_MIDDLEUP?=?0x0040;//?模拟鼠标中键抬起
3、为鼠标点击添加点击函数
public?static?extern?void?mouse_event(int?dwFlags,?int?dx,?int?dy,?int?dwData,?int?dwExtraInfo);
?????????private?void?button2_Click(object?sender,?EventArgs?e)????????{????????????int?x?=?int.Parse(textBox1.Text);????????????int?y?=?int.Parse(textBox2.Text);
//绝对位置????????????mouse_event(MOUSEEVENTF_MOVE?|?MOUSEEVENTF_ABSOLUTE,?x?*?65535?/?1600,?y?*?65535?/?900,?0,?0);//移动到需要点击的位置????????????mouse_event(MOUSEEVENTF_LEFTDOWN?|?MOUSEEVENTF_ABSOLUTE,?x?*?65535?/?1600,?y?*?65535?/?900,?0,?0);//点击????????????mouse_event(MOUSEEVENTF_LEFTUP?|?MOUSEEVENTF_ABSOLUTE,?x?*?65535?/?1600,?y?*?65535?/?900,?0,?0);//抬起
//相对位置??指的是相对于当前鼠标的相对位置
????????????mouse_event(MOUSEEVENTF_MOVE?,?x?,?y,?0,?0);//移动????????????mouse_event(MOUSEEVENTF_LEFTDOWN?,?x?,?y,?0,?0);//点击????????????mouse_event(MOUSEEVENTF_LEFTUP?,?x?,?y?,?0,?0);//抬起
????????}
VB mouse_event 模拟鼠标移动问题 帮忙找错!
mouse_event MOUSEEVENTF_MOVE + MOUSEEVENTF_ABSOLUTE, Me.ScaleX(100, 3, 1) * 65535 / Screen.Width, 0, 0, 0
解释:
MOUSEEVENTF_ABSOLUTE 是让鼠标指针按绝对位置移动。如果是相对移动,则实际的移动位置要受控制面板中对鼠标指针移动速度及移动精度的影响,也就是说,在不同的电脑上,鼠标指针相对移动后的位置很可能会出现截然不同的情况,所以最好不要用相对移动,改用绝对移动。
Me.ScaleX(100, 3, 1)是把100像素转为缇(Twip)
Screen.Width是屏幕的横向分辨率(单位是缇),这样就使程序适应所有显示器
vb6.0 中mouse_event不管用,不知哪里问题?
函数声明了吗?
Private Declare Sub mouse_event Lib "user32" (ByValdwFlags As Long, ByVal dx As
Long, ByValdy As Long, ByValcButtons As Long, ByValdwExtraInfo As Long)