Visual Basic Send Mouse Click to some coordinate



Private Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
Private 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)
Private Const MOUSEEVENTF_LEFTDOWN = &H2
Private Const MOUSEEVENTF_LEFTUP = &H4
Private Const MOUSEEVENTF_RIGHTDOWN = &H8
Private Const MOUSEEVENTF_RIGHTUP = &H10

Private Sub Command1_Click()
    SetCursorPos 20, 755 'start menu coordinate
    mouse_event MOUSEEVENTF_LEFTDOWN + MOUSEEVENTF_LEFTUP, 500, 515, 0, 0
End Sub

Contoh Project Download Di SINI

1 komentar:

Specter mengatakan...

kak, kalau kita klik di sembarang tempat, tapi form nya tidak focus, contoh kita buka notepad dan klik, cara hitung cordinat nya gimana?