Option Explicit
Private Declare Function CreateSemaphore Lib "kernel32" Alias "CreateSemaphoreA" (ByVal lpSemaphoreAttributes As Long, ByVal lInitialCount As Long, ByVal lMaximumCount As Long, ByVal lpName As String) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
Private Type POINTAPI
x As Long
y As Long
End Type
Private Const ERROR_ALREADY_EXISTS = 183&
Dim z As POINTAPI
Dim fFile
Private Sub cmdplay_Click()
fFile = FreeFile
Open Text1.Text For Input As fFile
tmrPlay.Interval = 1
End Sub
Private Sub cmdRecord_Click(Index As Integer)
On Error Resume Next
Kill Text1.Text
tmrRecord.Interval = 1
End Sub
Private Sub Stop_Click()
tmrRecord.Interval = 0
tmrPlay.Interval = 0
End Sub
Private Sub tmrPlay_Timer()
Dim strPos As String
Dim cv_X As Long
Dim cv_Y As Long
If EOF(fFile) = False Then
Line Input #fFile, strPos
cv_X = CLng(Trim(Mid(strPos, 4, InStr(1, strPos, "Y:") - 4)))
cv_Y = CLng(Trim(Mid(strPos, InStr(1, strPos, "Y:") + 3, Len(strPos) - (InStr(1, strPos, "Y:") + 2))))
SetCursorPos сv_X, сv_Y
Else
Close fFile
tmrPlay.Interval = 0
End If
End Sub
Private Sub tmrRecord_Timer()
Dim pos As POINTAPI
Dim frFile
frFile = FreeFile
GetCursorPos pos
Open Text1.Text For Append As frFile
Print #frFile, "X: " & Trim(Str(pos.x)) & " Y: " & Trim(Str(pos.y))
Close frFile
End Sub