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
我试图让光标等待几秒钟然后再单击右键。我搜索过并找到了一些不太符合我想做的复杂解决方案。
这可以通过简单的鼠标事件来完成吗?
答案 0 :(得分:0)
我不确定mouse_event正在做什么,但你应该能够使用Timer等待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