vb.net把鼠标固定 vb鼠标停留显示提示信息( 二 )


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.YvbCrLf
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.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 怎么用SendInput来实现鼠标移动到指定位置呢?您好,建议您使用mouse_event或者 Cursor.Position来实现 。例如:
1. 您需要将鼠标移动dx, dy的位置 。
Public Sub MouseMoveBy(ByVal dx As Integer, ByVal dy As Integer)
Cursor.Position = New Point(Cursor.Position.X + dx, Cursor.Position.Y + dy)
End Sub
或者
Public Sub MouseMoveBy(ByVal dx As Integer, ByVal dy As Integer)
mouse_event(0, dx, dy, 0, 0)
End Sub
2. 您需要将鼠标移动到x, y的位置
Public Sub MouseMoveTo(ByVal x As Integer, ByVal y As Integer)
Cursor.Position = New Point(x, y)
End Sub
请您试一下 。
【vb.net把鼠标固定 vb鼠标停留显示提示信息】关于vb.net把鼠标固定和vb鼠标停留显示提示信息的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站 。

推荐阅读