RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
vb点虐 自定义鼠标 vbs实现鼠标点击

VB.NET改变鼠标位置和让鼠标消失

几乎找不到真正VB.NET的api,都是自己将VB的api改成VB.NET的api,我的理解是声明中对应输入是H的地方保留Long,其他的Long改成Integer,既然VB.NET连MSDN都找不到较全的api说明档祥盯,不保证api的用法在VB.NET其他版行和本中适用。

创新互联建站专注为客户提供全方位的互联网综合服务,包含不限于做网站、网站设计、辽阳网络推广、微信小程序定制开发、辽阳网络营销、辽阳企业策划、辽阳品牌公关、搜索引擎seo、人物专访、企业宣传片、企业代运营等,从售前售中售后,我们都将竭诚为您服务,您的肯定,是我们最大的嘉奖;创新互联建站为所有大学生创业者提供辽阳建站搭建服务,24小时服务热线:13518219792,官方网址:www.cdcxhl.com

给你个好玩的例子,包括鼠标的隐藏(Ctrl_↓)、显示(Ctrl_↑),移动、点击

在Form1上放上2个TextBox,其中TextBox1.Multiline = True,并且面积大些,2个Button,运行后在TextBox1中点击一下会记录位置,移开鼠标,点宴数击移动或点击Button,可模拟在TextBox1中的点击

Public Class Form1

Public My_MousePosition As Point

'模拟鼠标移动、点击

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

'定义光标的位置

Declare Function SetCursorPos Lib "user32" Alias "SetCursorPos" (ByVal x As Integer, ByVal y As Integer) As Integer

'鼠标的隐藏

Declare Function ShowCursor Lib "user32" Alias "ShowCursor" (ByVal bShow As Integer) As Integer

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

TextBox1.Multiline = True

Button1.Text = "点击"

Button2.Text = "移动"

Me.KeyPreview = True

End Sub

Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown

If e.Control And e.KeyCode = Keys.Down Then ShowCursor(0)

If e.Control And e.KeyCode = Keys.Up Then ShowCursor(1)

End Sub

Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove

TextBox2.Text = MousePosition.X " " MousePosition.Y

End Sub

Private Sub TextBox1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TextBox1.MouseClick

My_MousePosition = MousePosition

TextBox1.Text = My_MousePosition.X " " My_MousePosition.Y vbCrLf

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

SetCursorPos(My_MousePosition.X, My_MousePosition.Y)

mouse_event(H2, 0, 0, 0, 0)

mouse_event(H4, 0, 0, 0, 0)

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

SetCursorPos(My_MousePosition.X, My_MousePosition.Y)

End Sub

End Class

其中

mouse_event Lib "user32" (ByVal dwFlags As Long

的dwFlags的代码是

Const MOUSEEVENTF_LEFTDOWN = H2

Const MOUSEEVENTF_LEFTUP = H4

Const MOUSEEVENTF_MIDDLEDOWN = H20

Const MOUSEEVENTF_MIDDLEUP = H40

Const MOUSEEVENTF_MOVE = H1

Const MOUSEEVENTF_ABSOLUTE = H8000

Const MOUSEEVENTF_RIGHTDOWN = H8

Const MOUSEEVENTF_RIGHTUP = H10

vb点虐 中 怎么实现 当鼠标移动到某控件时 改变鼠标的形状

属性里面先把UseWaitCursor改为true然后再改Cursor的属性。选择一个你要的形状

VB.NET自定义控件中如何使用鼠标离开事件?

那就不要在自定义控件里写,要在调用窗口里写,这时就是一个整体。

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

调用api

在Visual Baisc点虐 中的声明:

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点虐 自定义鼠标 vbs实现鼠标点击
网站网址:http://lswzjz.com/article/ddpeigh.html