AlmarM Posted May 4, 2009 Posted May 4, 2009 (edited) Hello,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 = 1Codeexpandcollapse popup#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 EndFuncExample$Var = _Mouse_Capture(5) _Mouse_Play($Var)Tell me what you think. Update:- Added mouseclick capture- Added mouseup and down capture - (WideBoyDixon)AlmarM Edited May 5, 2009 by AlmarM Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.
UEZ Posted May 4, 2009 Posted May 4, 2009 Funny idea Thanks! UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
WideBoyDixon Posted May 4, 2009 Posted May 4, 2009 Nice idea. Perhaps it would be better if it captured mouse clicks too? WBD [center]Wide by name, Wide by nature and Wide by girth[u]Scripts[/u]{Hot Folders} {Screen Calipers} {Screen Crosshairs} {Cross-Process Subclassing} {GDI+ Clock} {ASCII Art Signatures}{Another GDI+ Clock} {Desktop Goldfish} {Game of Life} {3D Pie Chart} {Stock Tracker}[u]UDFs[/u]{_FileReplaceText} {_ArrayCompare} {_ToBase}~ My Scripts On Google Code ~[/center]
Skrip Posted May 5, 2009 Posted May 5, 2009 Very nice! Mouse clicks would be nice though. [left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]
AlmarM Posted May 5, 2009 Author Posted May 5, 2009 (edited) Hmm yeah, mouse clicks. Ill try adding it. Thanks! AlmarMEDIT: Added mouseclicks. View first post!Any more ideas? Edited May 5, 2009 by AlmarM Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.
WideBoyDixon Posted May 5, 2009 Posted May 5, 2009 Rather than MouseClick, perhaps you could use MouseDown/MouseUp so that I could capture and reply drag-and-drop? WBD [center]Wide by name, Wide by nature and Wide by girth[u]Scripts[/u]{Hot Folders} {Screen Calipers} {Screen Crosshairs} {Cross-Process Subclassing} {GDI+ Clock} {ASCII Art Signatures}{Another GDI+ Clock} {Desktop Goldfish} {Game of Life} {3D Pie Chart} {Stock Tracker}[u]UDFs[/u]{_FileReplaceText} {_ArrayCompare} {_ToBase}~ My Scripts On Google Code ~[/center]
AlmarM Posted May 5, 2009 Author Posted May 5, 2009 Rather than MouseClick, perhaps you could use MouseDown/MouseUp so that I could capture and reply drag-and-drop?WBDDo you have any ideas how to record the mousedown / up? And even playback?AlmarM Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.
WideBoyDixon Posted May 5, 2009 Posted May 5, 2009 Something like this?: expandcollapse popup#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 WBD [center]Wide by name, Wide by nature and Wide by girth[u]Scripts[/u]{Hot Folders} {Screen Calipers} {Screen Crosshairs} {Cross-Process Subclassing} {GDI+ Clock} {ASCII Art Signatures}{Another GDI+ Clock} {Desktop Goldfish} {Game of Life} {3D Pie Chart} {Stock Tracker}[u]UDFs[/u]{_FileReplaceText} {_ArrayCompare} {_ToBase}~ My Scripts On Google Code ~[/center]
AlmarM Posted May 5, 2009 Author Posted May 5, 2009 Added mousedown and up! View first post! AlmarM Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.
UEZ Posted May 5, 2009 Posted May 5, 2009 One suggestion to avoid high cpu load when play back mouse movements:add a Sleep(20) to the for...next loop in function Func _Mouse_Play($fCapture, $fSpeed = 1).UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
PhoenixXL Posted November 14, 2012 Posted November 14, 2012 One suggestion to avoid high cpu load when play back mouse movementsSleep wouldnt be alone able to reduce much the CPU loadHencea MouseHook would be more efficient My code: PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners. MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.
Moderators Melba23 Posted November 14, 2012 Moderators Posted November 14, 2012 PhoenixXL, And you think it was worth necro-posting after 3 1/2 years to say that? Guess what? I do not, so please think twice before posting next time. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
techbard Posted November 15, 2012 Posted November 15, 2012 How about adding import/export text command file? like this... mousemove(0, 0) mousemove(1, 0) mousemove(2, 0) mousemove(3, 0) ... sleep(300)
Moderators Melba23 Posted November 15, 2012 Moderators Posted November 15, 2012 techbard,What part of my previous post was not clear? Do NOT necro-post again! M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now