新网创想网站建设,新征程启航

为企业提供网站建设、域名注册、服务器等服务

vb.net鼠标右击按钮 vb控制鼠标点击

VB.NET鼠标自动右击代码

调用api

从事联通机房服务器托管,服务器租用,云主机,网页空间,空间域名,CDN,网络代维等服务。

在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如何右击ListBoxx选择文件?

这回没分不写代码,哈哈......

利用listbox的MouseDown事件获取当前是哪个鼠标按键点击了控件;

通过MouseEventArgs事件类的Location属性获取鼠标在listbox中的坐标;

通过listbox的行高来计算鼠标在listbox的哪一行;

通过listbox的SelectedIndex属性来选定鼠标所在的那一行。

PS:算了,好人做到底吧!

Private Sub ListBox1_MouseDown(sender As Object, e As MouseEventArgs) _

Handles ListBox1.MouseDown

If e.Button = Windows.Forms.MouseButtons.Right Then

Dim ht As Integer = ListBox1.ItemHeight

Dim rect As New Rectangle _

(0, 0, ListBox1.ClientSize.Width, ht)

For i As Integer = 0 To ListBox1.Items.Count - 1

If rect.Contains(e.Location) Then

ListBox1.SelectedIndex = i

Exit For

Else

rect.Y += ht

End If

Next

End If

End Sub

vb.net,我有一个鼠标右键点击的事件,我想在这个事件里面加入鼠标左键点击的动作,

你已经有了“鼠标右键点击的事件”

说明你肯定已经有了if e.button=windows.forms.mousebuttons.right then

你只需要找到这条语句,通常这句话应该在你的mouseclick事件中。

这条语句改成

if e.button=windows.forms.mousebuttons.left or e.button=windows.forms.mousebuttons.right then

就可以了!

^_^


网页标题:vb.net鼠标右击按钮 vb控制鼠标点击
网页网址:http://www.wjwzjz.com/article/dodchjd.html
在线咨询
服务热线
服务热线:028-86922220
TOP