7月7日 如何控制滑鼠??

很多人都想知道巴
其實這是用"為卵"XP釋出的API來用的
廢話不多說 看原始碼就知道了
VB.net 的寫法
Public Class Form1
Declare Function SetCursorPos Lib "user32" (ByVal x As Integer, ByVal y As Integer) As Integer
Declare Function mouse_event Lib "user32" (ByVal dwFlags As Integer, ByVal dx As Integer, ByVal dy As Integer, ByVal cButtons As Integer, ByVal dwExtraInfo As Integer) As Integer
Dim k As Long
Dim sx, sy, l, w, tox, toy As Long
Private Sub Form_Load()
sx = 131
sy = 131
tox = sx
toy = sy
Timer1.Start()
Timer1.Interval = 1

'MsgBox("Q")
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Form_Load()
End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

' tox = tox + 10
'toy = toy + 10
If tox <= 902 Then
tox = tox + 10
Else
tox = sx
toy = toy + 10
End If
If toy > 627 Then
End
End If
SetCursorPos(tox, toy)
mouse_event(&H6, 0, 0, 0, 0) '點鼠左鍵
' RichTextBox1.Text = RichTextBox1.Text + toy.ToString + vbCrLf

End Sub
End Class

呼叫API:Declare Function SetCursorPos Lib "user32" (ByVal x As Integer, ByVal y As Integer) As Integer
Declare Function mouse_event Lib "user32" (ByVal dwFlags As Integer, ByVal dx As Integer, ByVal dy As Integer, ByVal cButtons As Integer, ByVal dwExtraInfo As Integer) As Integer

API裡的方法: SetCursorPos(tox, toy) '屬標移動到的位址
mouse_event(&H6, 0, 0, 0, 0) '點鼠左鍵

其實有很多方法這只是其中兩種

駐:&H6 屬標動作代碼(左鍵單擊)

其他自己式\式看ㄅ??

留言

這個網誌中的熱門文章

angular 如何Http 如何設定 CORS (Cross-Origin Resource Sharing)

Google Map 單車路徑計算坡度和角度小工具

Google URL Shortener API 快速教學