マウス操作

Windows版API

#If Win64 Then
Declare PtrSafe 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)
Declare PtrSafe Function SetCursorPos Lib "User32" (ByVal x As Long, ByVal y As Long) As LongLong
#Else
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)
Declare Function SetCursorPos Lib "User32" (ByVal x As Long, ByVal y As Long) As Long

#End If
#If VBA7 Then
Declare PtrSafe Sub MessageBeep Lib "User32" (ByVal n As Long)
#Else
Declare Sub MessageBeep Lib "User32" (ByVal n As Long)
#End If

Private Const MOUSEEVENTF_LEFTUP As Long = &H4
Private Const MOUSEEVENTF_LEFTDOWN As Long = &H2
Private Const MOUSEEVENTF_RIGHTUP As Long = &H10
Private Const MOUSEEVENTF_RIGHTDOWN As Long = &H8

Sub butten1()
Call SetCursorPos(770, 100)
Call mouse_event(&H2, 0, 0, 0, 0)
Call mouse_event(&H4, 0, 0, 0, 0)
End Sub

コメント

タイトルとURLをコピーしました