返回列表 上一主題 發帖

如何監控滑鼠點擊某個位置

要用到API喔~

Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Type POINTAPI
    X As Long
    Y As Long
End Type
Public Function GethWnd() As Long
    Dim lpPoint As POINTAPI
    GetCursorPos lpPoint
    GethWnd = WindowFromPoint(lpPoint.X, lpPoint.Y)
    MsgBox lpPoint.X
    MsgBox lpPoint.Y
End Function
若是我回答,使您滿意,請您讓我知道!                  
若是我的回覆,您仍有其他見解,也請您不嗇指教!

TOP

一個簡單的"移動滑鼠點撃" API卻是好幾個動作
要活用API 先要了解有哪一些API可以用~ (小弟不才 會用的也只有這幾個>"<)
我們拆兩個部分來談 1.滑鼠移動 2.滑鼠設定

1.滑鼠移動 XY就是您的座標 至於如何移動到"畫面正中央位置" 就自己算了~
Declare Function SetCursorPos Lib "user32" (ByVal X As Long, ByVal Y As Long) As Long
Sub MoveMouse()
    Dim X As Integer
    Dim Y As Integer
    X = 500
    Y = 150
    Call SetCursorPos(X, Y)
End Sub

2.滑鼠設定
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)
Sub SetMouse()
    Call mouse_event(&H2 Or &H4, 0, 0, 0, 0)
End Sub
&H2 就是左鍵按下
&H4 就是左鍵放開
若是我回答,使您滿意,請您讓我知道!                  
若是我的回覆,您仍有其他見解,也請您不嗇指教!

TOP

        靜思自在 : 君子如水,隨方就圓,無處不自在。
返回列表 上一主題