I was a little bored today and I came up with this. Mayby it could be usefull for someone.
Note: (Human playback speed)
$fDelay = 50
$fSpeed = 1
Code
#include-once #include <Misc.au3> ; #FUNCTION# ================================================================================================= ; Name...........: _Mouse_Capture() ; Description ...: Captures the x and y pos for a given time. ; Syntax.........: _Mouse_Capture($fTime, $fDelay = 10) ; Parameters ....: $fTime = For how long it should capture the movind mouse (Time in seconds). ; $fDelay = The capture delay (Default = 10). ; Errors ........: - ; Return values .: $_Return ; Author ........: Almar Mulder (AlmarM) ; Modified.......: - ; Remarks .......: - ; Related .......: _Mouse_Play() ; Link ..........: - ; Example .......: Yes ; #FUNCTION# ================================================================================================= Func _Mouse_Capture($fTime, $fDelay = 10) Local $_PosX, $_PosY Local $_fDown[2] = [0, 0] Local $_Return[2] $_Start = TimerInit() Do $_Stop = TimerDiff($_Start) $_GetPos = MouseGetPos() $_PosX &= $_GetPos[0] & "," $_PosY &= $_GetPos[1] & "," If _IsPressed("01") Then If $_fDown[0] = 0 Then $_PosX &= $_GetPos[0] & "ld," $_PosY &= $_GetPos[1] & "ld," $_fDown[0] = 1 EndIf Else If $_fDown[0] = 1 Then $_PosX &= $_GetPos[0] & "lu," $_PosY &= $_GetPos[1] & "lu," $_fDown[0] = 0 EndIf EndIf If _IsPressed("02") Then If $_fDown[1] = 0 Then $_PosX &= $_GetPos[0] & "rd," $_PosY &= $_GetPos[1] & "rd," $_fDown[1] = 1 EndIf Else If $_fDown[1] = 1 Then $_PosX &= $_GetPos[0] & "ru," $_PosY &= $_GetPos[1] & "ru," $_fDown[1] = 0 EndIf EndIf Sleep($fDelay) Until $_Stop >= $fTime * 1000 $_Return[0] = $_PosX $_Return[1] = $_PosY Return $_Return EndFunc ; #FUNCTION# ================================================================================================= ; Name...........: _Mouse_Play() ; Description ...: Plays the captured mouse path. ; Syntax.........: _Mouse_Play($fCapture, $fSpeed = 1) ; Parameters ....: $fCapture = The captured _Mouse_Capture variable. ; $fSpeed = The speed the mouse should move (Default = 1). ; Errors ........: - ; Return values .: - ; Author ........: Almar Mulder (AlmarM) ; Modified.......: - ; Remarks .......: - ; Related .......: _Mouse_Capture() ; Link ..........: - ; Example .......: Yes ; #FUNCTION# ================================================================================================= Func _Mouse_Play($fCapture, $fSpeed = 1) $_Trim_x = StringTrimRight($fCapture[0], 1) $_Trim_y = StringTrimRight($fCapture[1], 1) $_Split_x = StringSplit($_Trim_x, ",") $_Split_y = StringSplit($_Trim_y, ",") $_Max = $_Split_x[0] For $_i = 1 To $_Max MouseMove($_Split_x[$_i], $_Split_y[$_i], $fSpeed) If StringRight($_Split_x[$_i], 2) = "ld" Then MouseDown("left") If StringRight($_Split_x[$_i], 2) = "lu" Then MouseUp("left") If StringRight($_Split_x[$_i], 2) = "rd" Then MouseDown("right") If StringRight($_Split_x[$_i], 2) = "ru" Then MouseUp("right") Next EndFunc
Example
$Var = _Mouse_Capture(5) _Mouse_Play($Var)
Tell me what you think.
Update:
- Added mouseclick capture
- Added mouseup and down capture - (WideBoyDixon)
AlmarM
Edited by AlmarM, 05 May 2009 - 06:35 PM.




This topic is locked



