-
Notifications
You must be signed in to change notification settings - Fork 0
/
RandomBezier.ahk
71 lines (69 loc) · 2.71 KB
/
RandomBezier.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
RandomBezier.ahk
Copyright (C) 2012,2013 Antonio França
This script is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This script is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this script. If not, see <http://www.gnu.org/licenses/>.
*/
;========================================================================
;
; Function: RandomBezier
; Description: Moves the mouse through a random Bézier path
; URL (+info): --------------------
;
; Last Update: 30/May/2013 03:00h BRT
;
; Created by MasterFocus
; - https://github.com/MasterFocus
; - http://masterfocus.ahk4.net
; - http://autohotkey.com/community/viewtopic.php?f=2&t=88198
;
;========================================================================
RandomBezier( X0, Y0, Xf, Yf, O="" ) {
Time := RegExMatch(O,"i)T(\d+)",M)&&(M1>0)? M1: 200
RO := InStr(O,"RO",0) , RD := InStr(O,"RD",0)
N:=!RegExMatch(O,"i)P(\d+)(-(\d+))?",M)||(M1<2)? 2: (M1>19)? 19: M1
If ((M:=(M3!="")? ((M3<2)? 2: ((M3>19)? 19: M3)): ((M1=="")? 5: ""))!="")
Random, N, %N%, %M%
OfT:=RegExMatch(O,"i)OT(-?\d+)",M)? M1: 100, OfB:=RegExMatch(O,"i)OB(-?\d+)",M)? M1: 100
OfL:=RegExMatch(O,"i)OL(-?\d+)",M)? M1: 100, OfR:=RegExMatch(O,"i)OR(-?\d+)",M)? M1: 100
MouseGetPos, XM, YM
If ( RO )
X0 += XM, Y0 += YM
If ( RD )
Xf += XM, Yf += YM
If ( X0 < Xf )
sX := X0-OfL, bX := Xf+OfR
Else
sX := Xf-OfL, bX := X0+OfR
If ( Y0 < Yf )
sY := Y0-OfT, bY := Yf+OfB
Else
sY := Yf-OfT, bY := Y0+OfB
Loop, % (--N)-1 {
Random, X%A_Index%, %sX%, %bX%
Random, Y%A_Index%, %sY%, %bY%
}
X%N% := Xf, Y%N% := Yf, E := ( I := A_TickCount ) + Time
While ( A_TickCount < E ) {
U := 1 - (T := (A_TickCount-I)/Time)
Loop, % N + 1 + (X := Y := 0) {
Loop, % Idx := A_Index - (F1 := F2 := F3 := 1)
F2 *= A_Index, F1 *= A_Index
Loop, % D := N-Idx
F3 *= A_Index, F1 *= A_Index+Idx
M:=(F1/(F2*F3))*((T+0.000001)**Idx)*((U-0.000001)**D), X+=M*X%Idx%, Y+=M*Y%Idx%
}
MouseMove, %X%, %Y%, 0
Sleep, 1
}
MouseMove, X%N%, Y%N%, 0
Return N+1
}