Jump to content

How to speed up the mouse moviment...


Luigi
 Share

Recommended Posts

This is an order of magnitude faster than the MouseMove() function, even after adjusting MouseClick* options with Opt():

DllCall('user32.dll',"bool","SetCursorPos","int",$iX,"int",$iY)

*also - use a DLL handle (via DLLOpen('user32.dll') as the 1st parameter to speed it up further

Edited by Ascend4nt
Link to comment
Share on other sites

@John: I try with MouseMove with 0 option to velocity, but, is very slow to... kkkk about the code in YouTube, next time I put code here too! 8D Thans for your reply.

@Ascend4nt: Thanks for your replay, I try some scripts with your tip, but I have more sucess with Zedna's tip.

@Zedna: thank you, this way make a good result to my script.

Look it now...

8D

Now I try draw some geometric pictures...

The script is here...

#Include <WinAPI.au3>
#include <Constants.au3>
If WinExists("[CLASS:TMainForm]") = 1 Then
WinActivate("[CLASS:TMainForm]")
WinWaitActive("[CLASS:TMainForm]")
Else
Run("C:\Program Files (x86)\PhotoFiltre Studio X\pfstudiox.exe","",@SW_MAXIMIZE)
WinActivate("[CLASS:TMainForm]")
WinWaitActive("[CLASS:TMainForm]")
EndIf
$x_koef = 65535/@DesktopWidth
$y_koef = 65535/@DesktopHeight
$User32 = DllOpen("User32.dll")
Global $xi = 96, $xf = 1262, $yi = 114, $yf = 699
Global $passox = 20, $passoy = 20, $fonte = 20
_NewPicture(1167,586)
_Origem()
_PenTool(3)
_Color("primary",Random(0,38,1))

For $k = 1 to 1
_Color("primary",Random(0,38,1))
_PenTool(Random(0,5,1))
_Letter("0.5,2,1,1.5,2,1.5,2.5,2,2.5,4.5,2.5,2.5,2,3,1,3,0.5,3.5,0.5,4,1,4.5,2,4.5,2.5,4");a
$passox += 60
_Color("primary",Random(0,38,1))
_PenTool(Random(0,5,1))
_Letter("0.5,1.5,0.5,4.5,0.5,3,1,2.5,2,2.5,2.5,3,2.5,4,2,4.5,1,4.5,0.5,4");b
$passox += 60
_Color("primary",Random(0,38,1))
_PenTool(Random(0,5,1))
_Letter("2.5,3,2,2.5,1,2.5,0.5,3,0.5,4,1,4.5,2,4.5,2.5,4");c
$passox += 60
_Color("primary",Random(0,38,1))
_PenTool(Random(0,5,1))
_Letter("2.5,1.5,2.5,4,2,4.5,1,4.5,0.5,4,0.5,3,1,2.5,2,2.5,2.5,3,2.5,4.5");d
$passox += 60
_Color("primary",Random(0,38,1))
_PenTool(Random(0,5,1))
_Letter("2.5,4.35,2,4.5,1,4.5,0.5,4,0.5,3,1,2.5,2,2.5,2.5,3,2.5,3.5,0.5,3.5");e
$passox += 60
_Color("primary",Random(0,38,1))
_PenTool(Random(0,5,1))
_Letter("2.5,2,2,1.5,1.5,1.5,1,2,1,-4.5,0.5,3,1.5,3");f
$passox += 50
_Color("primary",Random(0,38,1))
_PenTool(Random(0,5,1))
_Letter("2.5,3,2,2.5,1,2.5,0.5,3,0.5,4,1,4.5,2,4.5,2.5,-4,2.5,2.5,2.5,5,2,5.5,1,5.5,0.5,5.25");g
$passox += 60
_Color("primary",Random(0,38,1))
_PenTool(Random(0,5,1))
_Letter("0.5,1.5,0.5,-4.5,0.5,3,1,2.5,2,2.5,2.5,3,2.5,4.5");h
$passox += 60
_Color("primary",Random(0,38,1))
_PenTool(Random(0,5,1))
_Letter("0.5,1.5,0.5,-1.5,0.5,2.5,0.5,4.5")
$passox += 20
_Color("primary",Random(0,38,1))
_PenTool(Random(0,5,1))
_Letter("2,1.5,2,-1.5,2,2.5,2,5,1.5,5.5,1,5.5,0.5,5")
$passox += 60
_Color("primary",Random(0,38,1))
_PenTool(Random(0,5,1))
_Letter("0.5,1.5,0.5,-4.5,0.5,3.5,2,-2,1,3,2,-4.5");k
$passox += 50
_Color("primary",Random(0,38,1))
_PenTool(Random(0,5,1))
_Letter("0.5,1.5,0.5,4.5")
$passox += 20
_Color("primary",Random(0,38,1))
_PenTool(Random(0,5,1))
_Letter("0.5,1.95,0.5,-4.5,0.5,2.5,1,2,1.5,2.5,1.5,-4.5,1.5,2.5,2,2,2.5,2.5,2.5,-4.5")
$passox += 60
_Color("primary",Random(0,38,1))
_PenTool(Random(0,5,1))
_Letter("0.5,1.95,0.5,-4.5,0.5,2.5,1,2,1.5,2.5,1.5,-4.5")
$passox += 40
_Color("primary",Random(0,38,1))
_PenTool(Random(0,5,1))
_Letter("2.5,3,2,2.5,1,2.5,0.5,3,0.5,4,1,4.5,2,4.5,2.5,4,2.5,3")
$passox += 60
_Color("primary",Random(0,38,1))
_PenTool(Random(0,5,1))
_Letter("0.5,2.5,0.5,-5.5,0.5,3,1,2.5,2,2.5,2.5,3,2.5,4,2,4.5,1,4.5,0.5,4")
$passox += 60
_Color("primary",Random(0,38,1))
_PenTool(Random(0,5,1))
_Letter("2.5,2.5,2.5,4,2,4.5,1,4.5,0.5,4,0.5,3,1,2.5,2,2.5,2.5,3,2.5,5.5")
$passox += 60
_Color("primary",Random(0,38,1))
_PenTool(Random(0,5,1))
_Letter("2,3,1.5,2.5,1,2.5,0.5,3,0.5,4.5,0.5,2.5")
$passox += 40
_Color("primary",Random(0,38,1))
_PenTool(Random(0,5,1))
_Letter("2.5,3,2,2.5,1,2.5,0.5,3,1,3.5,2,3.5,2.5,4,2,4.5,1,4.5,0.5,4")
$passox += 50
_Color("primary",Random(0,38,1))
_PenTool(Random(0,5,1))
_Letter("1,1.5,1,4,1.5,4.5,2,-4.5,0.5,2.5,1.5,2.5")
$passox += 50
_Color("primary",Random(0,38,1));_PenTool(Random(0,5,1))
_Letter("0.5,2.5,0.5,4,1,4.5,1.5,4.5,2,-4,2,2.5,2,4.5")

$passox += 50
_Color("primary",Random(0,38,1));_PenTool(Random(0,5,1))
_Letter("0.5,2.5,1.5,4.5,2.5,-2.5"); 'v'

$passox = 20
$passoy = 120
;$passox += 50
_Color("primary",Random(0,38,1));_PenTool(Random(0,5,1))
_Letter("0.5,2,1.5,4.5,2,3,2.5,4.5,3.5,-2"); 'w'
$passox += 80
_Color("primary",Random(0,38,1));_PenTool(Random(0,5,1))
_Letter("0.5,2,2.5,-4.5,0.5,4.5,2.5,-2"); 'w'
$passox += 60
_Color("primary",Random(0,38,1));_PenTool(Random(0,5,1))
_Letter("0.5,2,2.5,2,0.5,4.5,2.5,4.5"); 'z'
If $passox >= 580 Then $passox = 20
Next
 

Exit
;===
Func _Letter($entrada = "0.5,2,1,1.5,2,1.5,2.5,2,2.5,4.5,2.5,2.5,2,3,1,3,0.5,3.5,0.5,4,1,4.5,2,4.5,2.5,4")
$base = StringSplit($entrada,",")
For $n = 1 to $base[0] Step 2
  _WinAPI_Mouse_Event(BitOR($MOUSEEVENTF_ABSOLUTE, $MOUSEEVENTF_MOVE, $MOUSEEVENTF_LEFTDOWN),($xi+$passox+$fonte*abs($base[$n]))*$x_koef,($xi+$passoy+$fonte*abs($base[$n+1]))*$y_koef)
  If $base[$n+1] < 0 Then _WinAPI_Mouse_Event(BitOR($MOUSEEVENTF_ABSOLUTE, $MOUSEEVENTF_LEFTUP),($xi+$passoy+$fonte*abs($base[$base[0]-1]))*$x_koef,($xi+$passox+$fonte*abs($base[$base[0]]))*$y_koef)
Next
_WinAPI_Mouse_Event(BitOR($MOUSEEVENTF_ABSOLUTE, $MOUSEEVENTF_LEFTUP),($xi+$passoy+$fonte*abs($base[$base[0]-1]))*$x_koef,($xi+$passox+$fonte*abs($base[$base[0]]))*$y_koef)
EndFunc
;===
Func _MouseClick($x, $y)
$x *= $x_koef
$y *= $y_koef
DllCall("User32.dll", "none", "mouse_event", "int", 32769, "int", $x, "int", $y, "int", 0, "int", 0) ; 32769 0x8001 BitOR($MOUSEEVENTF_ABSOLUTE, $MOUSEEVENTF_MOVE)
DllCall("User32.dll", "none", "mouse_event", "int", 32770, "int", $x, "int", $y, "int", 0, "int", 0) ; 32770 0x8002 BitOR($MOUSEEVENTF_ABSOLUTE, $MOUSEEVENTF_LEFTDOWN)
DllCall("User32.dll", "none", "mouse_event", "int", 32772, "int", $x, "int", $y, "int", 0, "int", 0) ; 32772 0x8004 BitOR($MOUSEEVENTF_ABSOLUTE, $MOUSEEVENTF_LEFTUP)
EndFunc
;===
Func _MouseMove($x, $y)
$x *= $x_koef
$y *= $y_koef
DllCall("User32.dll", "none", "mouse_event", "int", 32769, "int", $x, "int", $y, "int", 0, "int", 0) ; 32769 0x8001 BitOR($MOUSEEVENTF_ABSOLUTE, $MOUSEEVENTF_MOVE)
EndFunc
;===
Func _NewPicture($largura,$altura)
_MouseClick(19,60)
Send("{TAB 3}")
Send($largura)
Send("{TAB}")
Send($altura)
Send("{ENTER}")
_MouseClick(1168,126)
_MouseClick(644,62)
_MouseClick(662,254)
EndFunc
;===
Func _Origem()
_MouseMove($xi,$yi)
EndFunc
;===
Func _PenTool($pena = 0)
; 1292 x 340
_MouseClick(1292,340)
Switch $pena
  Case 0
   _MouseClick(1290,435)
  Case 1
   _MouseClick(1318,435)
  Case 2
   _MouseClick(1345,435)
  Case 3
   _MouseClick(1290,462)
  Case 4
   _MouseClick(1318,462)
  Case 5
   _MouseClick(1345,462)
  Case 6
   _MouseClick(1290,491)
  Case 7
   _MouseClick(1318,491)
  Case 8
   _MouseClick(1345,491)
  Case 9
   _MouseClick(1291,516)
  Case 10
   _MouseClick(1318,516)
  Case 11
   _MouseClick(1345,516)
EndSwitch
EndFunc
;===
Func _Color($botao = "primary",$cor = 0)
Local $x = 0, $y = 0, $z = 0
Do
For $x = 0 to 4
  For $y = 0 to 7
   If $z = $cor Then ExitLoop(2)
   $z +=1
  Next
Next
Until $z = $cor
;MouseClick($botao,1285 + $y * 10,179 + $x * 10,1,0)
_MouseClick(1285 + $y * 10,179 + $x * 10)
EndFunc
Edited by detefon

Visit my repository

Link to comment
Share on other sites

Here's the way to modify your code to use the DLLCall I mentioned:

Func _MouseClick($x, $y)
    DllCall($User32,"bool","SetCursorPos","int",$x,"int",$y)
    MouseClick('primary')
EndFunc
;===
Func _MouseMove($x, $y)
    DllCall($User32,"bool","SetCursorPos","int",$x,"int",$y)
EndFunc

The reason I use MouseClick() is because that's faster than the DLLCalls when used without x,y coordinates and delay options are 0. You'll need to add this somewhere at the top of the script to avoid click delays:

Opt("MouseClickDelay",0)
Opt("MouseClickDownDelay",0)

*Also, your '_Letter' function could probably be modified as such:

Func _Letter($entrada = "0.5,2,1,1.5,2,1.5,2.5,2,2.5,4.5,2.5,2.5,2,3,1,3,0.5,3.5,0.5,4,1,4.5,2,4.5,2.5,4")
    $base = StringSplit($entrada,",")
    For $n = 1 to $base[0] Step 2
        DllCall($User32,"bool","SetCursorPos","int",$xi+$passox+$fonte*abs($base[$n]),"int",$xi+$passoy+$fonte*abs($base[$n+1]))
        MouseDown("primary")
        If $base[$n+1] < 0 Then MouseUp("primary")
    Next
    MouseUp("primary")
EndFunc
Edited by Ascend4nt
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...