vb.net中mouse vb和vb net-成都创新互联网站建设

关于创新互联

多方位宣传企业产品与服务 突出企业形象

公司简介 公司的服务 荣誉资质 新闻动态 联系我们

vb.net中mouse vb和vb net

VB.NET mouse_event 双击对广联达不起作用,但是excel可以。

SetCursorPos(xr,yr)

遂宁ssl适用于网站、小程序/APP、API接口等需要进行数据传输应用场景,ssl证书未来市场广阔!成为创新互联建站的ssl证书销售渠道,可以享受市场价格4-6折优惠!如果有意向欢迎电话联系或者加微信:13518219792(备注:SSL证书合作)期待与您的合作!

sleep (1000) '移动鼠标后加个延时 先加大一点的没关系  测试有效后再缩短延时时间

其他行的sleep 也如此 再者你的leftdown 和 up 常量有先赋值吧

VB.NET模拟鼠标问题

Declare Sub mouse_event Lib "user32" Alias "mouse_event" (ByVal dwFlags As Integer, ByVal dx As Integer, ByVal dy As Integer, ByVal cButtons As Integer, ByVal dwExtraInfo As Integer)

Dim postion1 As New Point

mouse_event(H1 Or H8000, postion1.X * 65535 / 1366, postion1.Y * 65535 / 768, 0, 0)

'按绝对位置移动鼠标

'在鼠标坐标系统中,屏幕在水平和垂直方向上均匀分割成65535×65535个单元,

'当前所用显示屏分辨率为1366*768

'所以要进行如上转换

mouse_event(H2, 0, 0, 0, 0) '鼠标左键按下

mouse_event(H4, 0, 0, 0, 0) '鼠标左键弹起

msdn上有 mouse_event 的详解,大致使用如上

如何在VB.net中用程序控制鼠标移动和点击

调用api

在Visual Baisc.net中的声明:

Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)

Public Const MOUSEEVENTF_LEFTDOWN = H2 '模拟鼠标左键按下

Public Const MOUSEEVENTF_LEFTUP = H4 ’模拟鼠标左键释放

Public Const MOUSEEVENTF_MIDDLEDOWN = H20 '模拟鼠标中间键按下

Public Const MOUSEEVENTF_MIDDLEUP = H40 '模拟鼠标中间键释放

Public Const MOUSEEVENTF_RIGHTDOWN = H8 '模拟鼠标右键按下

Public Const MOUSEEVENTF_RIGHTUP = H10 '模拟鼠标右键释放

Public Const MOUSEEVENTF_MOVE = H1 '模拟鼠标指针移动

例:

mouse_event MOUSEEVENTF_LEFTDOWN,10,10,0,0

'在(10,10)模拟鼠标左键按下

VB.net怎样按住鼠标移动无边框窗体

1.在mouse事件中实现

2.调用windows API

实现方式为:

1.在mouse事件中实现

[csharp] view plain copy

Point mouseOff;//鼠标移动位置变量

bool leftFlag;//标签是否为左键

private void groupControl1_MouseUp(object sender, MouseEventArgs e)

{

if (leftFlag)

{

leftFlag = false;//释放鼠标后标注为false;

}

}

private void groupControl1_MouseMove(object sender, MouseEventArgs e)

{

if (leftFlag)

{

Point mouseSet = Control.MousePosition;

mouseSet.Offset(mouseOff.X, mouseOff.Y); //设置移动后的位置

Location = mouseSet;

}

}

private void groupControl1_MouseDown(object sender, MouseEventArgs e)

{

if (e.Button == MouseButtons.Left)

{

mouseOff = new Point(-e.X, -e.Y); //得到变量的值

leftFlag = true; //点击左键按下时标注为true;

}

}

private void groupControl1_MouseDown(object sender, MouseEventArgs e)

{

if (e.Button == MouseButtons.Left)

{

mouseOff = new Point(-e.X, -e.Y); //得到变量的值

leftFlag = true; //点击左键按下时标注为true;

}

}

2.调用windows API

调用前需要添加using System.Runtime.InteropServices;

[csharp] view plain copy

[DllImport("user32.dll")]

public static extern bool ReleaseCapture();

[DllImport("user32.dll")]

public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);

private void groupControl1_MouseDown(object sender, MouseEventArgs e)

{

if (e.Button == MouseButtons.Left)

{

ReleaseCapture(); //释放鼠标捕捉

//发送左键点击的消息至该窗体(标题栏)

SendMessage(Handle, 0xA1, 0x02, 0);

}

}


当前名称:vb.net中mouse vb和vb net
网页网址:http://kswsj.cn/article/hehcpc.html

其他资讯