VB.net : 稍等片刻再点击右键
VB.net : Wait a bit before right clicking
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Me.Cursor = New Cursor(Cursor.Current.Handle)
Cursor.Position = New Point(800, 500)
'mouse_event WaitFor2 seconds???
Cursor.Position = New Point(800, 500)
mouse_event(&H8)
Cursor.Position = New Point(800, 500)
mouse_event(&H10)
End Sub
我试图让光标在右键单击之前等待几秒钟。我搜索并发现了一些复杂的解决方案,这些解决方案并不是我想要做的。
这可以通过简单的鼠标事件完成吗?
我不确定 mouse_event 在做什么,但您应该可以使用计时器等待 2 秒。将计时器添加到您的表单(例如,将一个计时器从工具箱拖到设计器中的表单上。然后使用此代码。
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Me.Cursor = New Cursor(Cursor.Current.Handle)
Cursor.Position = New Point(800, 500)
Timer1.Interval = 2000
Timer1.Start()
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Cursor.Position = New Point(800, 500)
mouse_event(&H8)
Cursor.Position = New Point(800, 500)
mouse_event(&H10)
Timer1.Stop()
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Me.Cursor = New Cursor(Cursor.Current.Handle)
Cursor.Position = New Point(800, 500)
'mouse_event WaitFor2 seconds???
Cursor.Position = New Point(800, 500)
mouse_event(&H8)
Cursor.Position = New Point(800, 500)
mouse_event(&H10)
End Sub
我试图让光标在右键单击之前等待几秒钟。我搜索并发现了一些复杂的解决方案,这些解决方案并不是我想要做的。
这可以通过简单的鼠标事件完成吗?
我不确定 mouse_event 在做什么,但您应该可以使用计时器等待 2 秒。将计时器添加到您的表单(例如,将一个计时器从工具箱拖到设计器中的表单上。然后使用此代码。
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Me.Cursor = New Cursor(Cursor.Current.Handle)
Cursor.Position = New Point(800, 500)
Timer1.Interval = 2000
Timer1.Start()
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Cursor.Position = New Point(800, 500)
mouse_event(&H8)
Cursor.Position = New Point(800, 500)
mouse_event(&H10)
Timer1.Stop()
End Sub