vbnet鼠标按下,用vbs控制鼠标移动-成都快上网建站

vbnet鼠标按下,用vbs控制鼠标移动

VB.NET 使用鼠标HOOK判断是否按下鼠标左键 说明: 如图所示 我可怜的全部分数都给出来了,哪位大侠帮帮忙

在MouseDown或MouseUp事件中

成都创新互联公司是一家专注于成都网站设计、做网站、成都外贸网站建设公司与策划设计,代县网站建设哪家好?成都创新互联公司做网站,专注于网站建设十多年,网设计领域的专业建站公司;建站业务涵盖:代县等地区。代县做网站价格咨询:18980820575

Select Case e.Button

Case MouseButtons.Left

MsgBox("")

Case MouseButtons.Middle

MsgBox("'")

Case MouseButtons.Right

MsgBox("""")

End Select

即可知道是左键还是右键

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中用程序控制鼠标移动和点击

调用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模拟鼠标问题

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在MouseMove时检测鼠标是否处于左键是否处于按下的状态。

MouseMove里有个参数是Button,1是左键按下,2是右键按下,4是中间按下

求大神指点vb.net 怎么实现鼠标左键按住在移动鼠标达到选中文件的效果呀.我用mouse_even没有效果.

看图片背景,我又试了下资源管理器,文件是选中的状态

选中文件和选中文字,背景色是不同的


新闻标题:vbnet鼠标按下,用vbs控制鼠标移动
URL分享:http://kswjz.com/article/dsiisgj.html
扫二维码与项目经理沟通

我们在微信上24小时期待你的声音

解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流