重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
用一个全局变量计数,单击一次变量加1,计数到3或4时变量清0执行你的事件
创新互联主要从事做网站、网站建设、网页设计、企业做网站、公司建网站等业务。立足成都服务徐闻,10余年网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:028-86922220
Private clickCnt As Integer = 0
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
clickCnt += 1
If clickCnt = 3 Then
clickCnt = 0
MessageBox.Show("点击了3次")
End If
End Sub
调用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)模拟鼠标左键按下
长按你可以用计时器来实现啊,写个例子:
Private blCtrl As Boolean = False
Private Sub Form1_KeyDown(sender As Object, e As KeyEventArgs) Handles Me.KeyDown
If e.KeyCode = Keys.LControlKey Then blCtrl = True
End Sub
Private Sub Form1_KeyUp(sender As Object, e As KeyEventArgs) Handles Me.KeyUp
If e.KeyCode = Keys.LControlKey Then blCtrl = False
End Sub
然后你可以在计时器里检测blCtrl的状态来确定,不知道你的具体情况是什么样的
总之是用一个布尔变量来记录按键状态,配合计时器来达到你想要的功能
画点:
在PictureBox的Paint事件里面:
dim myGraphics=e.Graphics
Dim myPointArray As Point() = {New Point(0, 0), New Point(50, 30), New Point(30, 60)}
myGraphics.DrawPolygon(myPen, myPointArray)
画圆:
Dim g As Graphics
g = PictureBox1.CreateGraphics
g.FillEllipse(Brushes.Red, x, y, 10, 10)
Private Sub TextBox1_Click(sender As Object, e As EventArgs) Handles TextBox1.Click
TextBox1.SelectAll()
TextBox1.ForeColor = Color.Blue
End Sub
如果不想每次都这样的话,就加一个if判断TextBox1.ForeColor 是否是Color.Blue就可以了
1.定义变量记录键是否被按下,按下的累计时间
Dim 按下A键 As Boolean
Dim 按下A键时间 As Integer
2.添加一个TextBox1用于接收键盘事件,或者直接用窗体的键盘事件(确保KeyPreview为True)
在KeyDown事件中添加如下代码:
If e.Keycode = keys.A Then 按下A键 = True
在KeyUp事件中添加如下代码:
If e.Keycode = keys.A Then 按下A键 = False
3.添加一个Timer1控件,调整Timer1的Interval来决定按键频率,记得要把Timer1.Enable开启
在Tick事件中添加如下代码:
If 按下A键 = True
按下A键时间+=1
Call 音量设置(按下A键时间 * 10)
End If
PS: 按下的秒数 = 按下A键时间*Timer1.Interval / 1000