マウスの現座標はWindowsAPIのGetCursorPosで取得できました。
任意時間、マウス座標を取得する方法は以下です。
任意時間、マウス座標を取得する方法は以下です。
任意の時間マウスの座標を取得するサンプルコード
'■WindowsAPI取得のため、宣言(32bit/64bit)
#If Win64 Then
Declare PtrSafe Function GetCursorPos Lib "User32" (lpPoint As cPoint) As Long
#Else
Declare Function GetCursorPos Lib "User32" (lpPoint As cPoint) As Long
#End If
Type cPoint
x As Long
y As Long
End Type
Public Sub sample()
Dim c As cPoint
Dim sTime As Double
Dim eTime As Double
sTime = Timer
Do While Timer - sTime <= 5 '任意時間を指定 例では5秒
GetCursorPos c
'■マウスの現在座標を取得する
Debug.Print c.x & " " & c.y '290 46 例
eTime = Timer
Loop
'■StatusBarをクリアする
Application.StatusBar = False
End Sub
注意点
- 特にありません。



コメント