/
InputHandler.simba
815 lines (695 loc) · 20.6 KB
/
InputHandler.simba
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
{
============
InputHandler
============
}
var
MouseSpeed: Integer;
procedure getRealMousePos(var X, Y : Integer);
var
KMTarget, ITarget: Integer;
begin
{$IFDEF SMART}
if not IsTargetValid() then Writeln('Target invalid');
KMTarget := GetKeyMouseTarget;
ITarget := GetImageTarget;
if not findAndSetTarget('SMART', True) then
findAndSetTarget('Old', True);
GetMousePos(X, Y);
FreeTarget(GetImageTarget);
SetKeyMouseTarget(KMTarget);
SetImageTarget(ITarget);
X := X - 3;
Y := Y - 25;
{$ELSE}
GetMousePos(X, Y);
{$ENDIF}
end;
function getRealMousePnt(): TPoint;
var
x,y : integer;
begin
getRealMousePos(X, Y);
Result := Point(X, Y);
end;
function getMousePnt(): TPoint;
var
x,y : integer;
begin
getMousePos(X, Y);
Result := Point(X, Y);
end;
function isMouseInClient(): Boolean;
begin
result := pointInBox(getRealMousePnt(), intToBox(MSX1,MSY1,MIX2,MIY2));
end;
{*******************************************************************************
procedure Procedure brakeWindMouse(xs, ys, xe, ye, gravity, wind, minWait,
maxWait, targetArea: extended; reverse: boolean);
By: Flight
Description: Mouse movement based on distance to determine speed. Default slowed
speed at 20% from destination, if Double is set to true then slowed
speed also starts at origin and ends 80% to destination.
*******************************************************************************}
Procedure brakeWindMouse(xs, ys, xe, ye, gravity, wind, minWait, maxWait,
targetArea: extended; double: boolean);
var
T : Timer;
veloX,veloY,windX,windY,veloMag,dist,randomDist,lastDist,D: extended;
lastX,lastY,MSP,W,TDist: integer;
sqrt2,sqrt3,sqrt5,PDist,maxStep,dModA,dModB,nModA,nModB: extended;
begin
MSP := MouseSpeed;
sqrt2:= sqrt(2);
sqrt3:= sqrt(3);
sqrt5:= sqrt(5);
TDist := Distance(Round(xs), Round(ys), Round(xe), Round(ye));
if (TDist < 1) then
TDist := 1;
dModA := 0.88;
dModB := 0.95;
if (TDist > 220) then
begin
nModA := 0.08;
nModB := 0.04;
end else if (TDist <= 220) then
begin
nModA := 0.20;
nModB := 0.10;
end;
T.start();
repeat
if (T.timeElapsed() > 5000) then
break;
dist:= hypot(xs - xe, ys - ye);
wind:= minE(wind, dist);
if (dist < 1) then
dist := 1;
PDist := (dist/TDist);
if (PDist < 0.01) then
PDist := 0.01;
if Double then
begin
if (PDist <= dModA) then
begin
D := (Round((Round(dist)*0.3))/5);
if (D < 20) then
D := 20;
end else if (PDist > dModA) then
begin
if (PDist < dModB) then
D := RandomRange(5, 8)
else if (PDist >= dModB) then
D := RandomRange(3, 4);
end;
end;
if (PDist >= nModA) then
begin
D := (Round((Round(dist)*0.3))/5);
if (D < 20) then
D := 20;
end else if (PDist < nModA) then
begin
if (PDist >= nModB) then
D := RandomRange(5, 8)
else if (PDist < nModB) then
D := RandomRange(3, 4);
end;
if (D <= Round(dist)) then
maxStep := D
else
maxStep := Round(dist);
if dist >= targetArea then
begin
windX:= windX / sqrt3 + (random(round(wind) * 2 + 1) - wind) / sqrt5;
windY:= windY / sqrt3 + (random(round(wind) * 2 + 1) - wind) / sqrt5;
end else
begin
windX:= windX / sqrt2;
windY:= windY / sqrt2;
end;
veloX:= veloX + windX;
veloY:= veloY + windY;
veloX:= veloX + gravity * (xe - xs) / dist;
veloY:= veloY + gravity * (ye - ys) / dist;
if (hypot(veloX, veloY) > maxStep) then
begin
randomDist:= maxStep / 2.0 + random(round(maxStep) div 2);
veloMag:= sqrt(veloX * veloX + veloY * veloY);
veloX:= (veloX / veloMag) * randomDist;
veloY:= (veloY / veloMag) * randomDist;
end;
lastX:= Round(xs);
lastY:= Round(ys);
xs:= xs + veloX;
ys:= ys + veloY;
if (lastX <> Round(xs)) or (lastY <> Round(ys)) then
moveMouse(Round(xs), Round(ys));
W := (Random((Round(100/MSP)))*6);
if (W < 5) then
W := 5;
if Double then
if (PDist > dModA) then
W := Round(W*2.5)
else
W := Round(W*1.2);
wait(W);
lastdist:= dist;
until(hypot(xs - xe, ys - ye) < 1)
if (Round(xe) <> Round(xs)) or (Round(ye) <> Round(ys)) then
MoveMouse(Round(xe), Round(ye));
MouseSpeed := MSP;
end;
function isUptextMulti(Text: TStringArray): Boolean; forward;
{*******************************************************************************
Function humanWindMouse(xs, ys, xe, ye, gravity, wind, minWait,
maxWait, targetArea: extended): Boolean;
By: Flight
Description: ....
*******************************************************************************}
Function humanWindMouse(xs, ys, xe, ye, gravity, wind, minWait, maxWait, targetArea: extended; TxtArr: TStringArray = []): Boolean;
var
T : Timer;
veloX,veloY,windX,windY,veloMag,dist,randomDist,lastDist,D: extended;
lastX,lastY,MSP,W,TDist: integer;
sqrt2,sqrt3,sqrt5,maxStep,rCnc: extended;
txt : TStringArray;
begin
Result := False;
MSP := MouseSpeed;
sqrt2:= sqrt(2);
sqrt3:= sqrt(3);
sqrt5:= sqrt(5);
txt := TxtArr;
TDist := Distance(Round(xs), Round(ys), Round(xe), Round(ye));
T.start();
repeat
if length(txt) > 0 then
if isUpTextMulti(txt) then
Exit(true);
if (T.timeElapsed>10000) then
break;
dist:= hypot(xs - xe, ys - ye);
wind:= minE(wind, dist);
if (dist < 1) then
dist := 1;
D := (Round((Round(TDist)*0.3))/7);
if (D > 25) then
D := 25;
if (D < 5) then
D := 5;
rCnc := Random(6);
if (rCnc = 1) then
D := RandomRange(2,3);
if (D <= Round(dist)) then
maxStep := D
else
maxStep := Round(dist);
if dist >= targetArea then
begin
windX:= windX / sqrt3 + (random(round(wind) * 2 + 1) - wind) / sqrt5;
windY:= windY / sqrt3 + (random(round(wind) * 2 + 1) - wind) / sqrt5;
end else
begin
windX:= windX / sqrt2;
windY:= windY / sqrt2;
end;
veloX:= veloX + windX;
veloY:= veloY + windY;
veloX:= veloX + gravity * (xe - xs) / dist;
veloY:= veloY + gravity * (ye - ys) / dist;
if (hypot(veloX, veloY) > maxStep) then
begin
randomDist:= maxStep / 2.0 + random(round(maxStep) div 2);
veloMag:= sqrt(veloX * veloX + veloY * veloY);
veloX:= (veloX / veloMag) * randomDist;
veloY:= (veloY / veloMag) * randomDist;
end;
lastX:= Round(xs);
lastY:= Round(ys);
xs:= xs + veloX;
ys:= ys + veloY;
if (lastX <> Round(xs)) or (lastY <> Round(ys)) then
MoveMouse(Round(xs), Round(ys));
W := (Random((Round(100/MSP)))*6);
if (W < 5) then
W := 5;
if length(txt) >= 1 then
W := Round(W*0.6) // Speed it up a little for compensation
else
W := Round(W*0.9);
wait(W);
lastdist:= dist;
until(hypot(xs - xe, ys - ye) < 1)
if (Round(xe) <> Round(xs)) or (Round(ye) <> Round(ys)) then
MoveMouse(Round(xe), Round(ye));
end;
function itemsInBank(): Boolean; forward;
{*******************************************************************************
Function windMouseFunc(xs, ys, xe, ye, gravity, wind, minWait, maxWait,
targetArea: extended; Func: function: Boolean): Boolean;
By: Flight
Description: "Slowly" moves the mouse until either the target coordinate is
reached or the condition 'Func' is met.
*******************************************************************************}
Function windMouseFunc(xs, ys, xe, ye, gravity, wind, minWait, maxWait, targetArea: extended; Func: function: Boolean; Bank: Boolean = False): Boolean;
var
veloX,veloY,windX,windY,veloMag,dist,randomDist,lastDist,step: extended;
lastX,lastY,MSP,W,maxStep,X,Y: integer;
sqrt2,sqrt3,sqrt5: extended;
fX,fY,mX,mY: Integer;
B: TBox;
begin
if (Func()) then Exit(True);
Result := False;
MSP := MouseSpeed;
sqrt2 := sqrt(2);
sqrt3 := sqrt(3);
sqrt5 := sqrt(5);
repeat
dist:= hypot(xs - xe, ys - ye);
wind:= minE(wind, dist);
maxStep := (RandomRange(2, 4));
if dist >= targetArea then
begin
windX:= windX / sqrt3 + (random(round(wind) * 2 + 1) - wind) / sqrt5;
windY:= windY / sqrt3 + (random(round(wind) * 2 + 1) - wind) / sqrt5;
end else
begin
windX:= windX / sqrt2;
windY:= windY / sqrt2;
end;
veloX:= veloX + windX;
veloY:= veloY + windY;
veloX:= veloX + gravity * (xe - xs) / dist;
veloY:= veloY + gravity * (ye - ys) / dist;
if hypot(veloX, veloY) > maxStep then
begin
randomDist:= maxStep / 2.0 + random(round(maxStep) div 2);
veloMag:= sqrt(veloX * veloX + veloY * veloY);
veloX:= (veloX / veloMag) * randomDist;
veloY:= (veloY / veloMag) * randomDist;
end;
lastX:= Round(xs);
lastY:= Round(ys);
xs:= xs + veloX;
ys:= ys + veloY;
if (lastX <> Round(xs)) or (lastY <> Round(ys)) then
MoveMouse(Round(xs), Round(ys));
if (Func()) then
begin
MouseSpeed := MSP;
Exit(True);
end;
if Bank then
if (not itemsInBank()) then
begin
MouseSpeed := MSP;
Exit(false);
end;
if RBool then
W := (MSP + (Random(Round(MSP/4))))
else
W := (MSP - (RandomRange(Round(MSP/2), MSP-1)));
if (W < 1) then
W := 1;
wait(W);
step:= hypot(xs - lastX, ys - lastY);
lastdist:= dist;
until(hypot(xs - xe, ys - ye) < 1)
if (Round(xe) <> Round(xs)) or (Round(ye) <> Round(ys)) then
moveMouse(Round(xe), Round(ye));
MouseSpeed := MSP;
end;
{*******************************************************************************
procedure brakeMMouse(Pnt: TPoint; ranX, ranY: Integer; double: Boolean);
By: Flight
Description: Makes use of BrakeWindMouse; mouse speed decreases at 15% to
destination point. If Double is set to true then speed starts
slow and increases through the first 15% of the path.
*******************************************************************************}
Procedure brakeMMouse(Pnt: TPoint; ranX, ranY: Integer; double: Boolean);
var
randSpeed : extended;
X,Y,MS : integer;
begin
MS := MouseSpeed;
randSpeed := (random(MouseSpeed) / 2.0 + MouseSpeed) / 10.0;
getMousePos(X, Y);
brakeWindMouse(X, Y, RandomRange(Pnt.X-ranX, Pnt.X+ranX), RandomRange(Pnt.Y-ranY,Pnt.Y+ranY),
8, 3, 10.0/randSpeed, 15.0/randSpeed, 10.0*randSpeed, double);
MouseSpeed := MS;
end;
{*******************************************************************************
procedure accurateMMouse(Pnt: TPoint; ranX, ranY: Integer);
By: Flight
Description: Same as brakeMMouse but uses a much straighter path; required
for choosing tabbed options.
*******************************************************************************}
Procedure accurateMMouse(Pnt: TPoint; ranX, ranY: Integer);
var
randSpeed : extended;
X,Y,MS : integer;
begin
MS := MouseSpeed;
randSpeed := (random(MouseSpeed) / 2.0 + MouseSpeed) / 10.0;
getMousePos(X, Y);
brakeWindMouse(X, Y, RandomRange(Pnt.X-ranX, Pnt.X+ranX), RandomRange(Pnt.Y-ranY,Pnt.Y+ranY), 14, 3, 10.0/randSpeed, 15.0/randSpeed, 10.0*randSpeed, False);
MouseSpeed := MS;
end;
Function humanMMouseTxt(Pnt: TPoint; ranX, ranY: Integer; TxtArr: TStringArray): Boolean;
var
randSpeed: extended;
X,Y,MS: integer;
begin
Result := False;
MS := MouseSpeed;
randSpeed := (random(MouseSpeed) / 2.0 + MouseSpeed) / 10.0;
getMousePos(X, Y);
Result := humanWindMouse(X, Y, RandomRange(Pnt.X-ranX, Pnt.X+ranX), RandomRange(Pnt.Y-ranY,Pnt.Y+ranY), 7, 5, 10.0 / randSpeed, 15.0 / randSpeed, 10.0 * randSpeed, TxtArr);
end;
{*******************************************************************************
function humanMMouse(Pnt: TPoint; ranX, ranY: Integer): Boolean;
By: Flight
Description:...
*******************************************************************************}
Procedure humanMMouse(Pnt: TPoint; ranX, ranY: Integer);
var
randSpeed: extended;
X,Y,MS: integer;
begin
MS := MouseSpeed;
randSpeed := (random(MouseSpeed) / 2.0 + MouseSpeed) / 10.0;
getMousePos(X, Y);
humanWindMouse(X, Y, RandomRange(Pnt.X-ranX, Pnt.X+ranX), RandomRange(Pnt.Y-ranY,Pnt.Y+ranY), 7, 5, 10.0 / randSpeed, 15.0 / randSpeed, 10.0 * randSpeed, []);
MouseSpeed := MS;
end;
{*******************************************************************************
procedure shiftWindMouse(xs, ys, xe, ye, gravity, wind, minWait, maxWait, maxStep,
targetArea: extended);
By: Flight
Description: Mouse movement that shifts speed after every mouse 'step'
*******************************************************************************}
procedure shiftWindMouse(xs, ys, xe, ye, gravity, wind, minWait, maxWait, maxStep, targetArea: extended);
var
veloX,veloY,windX,windY,veloMag,dist,randomDist,lastDist,step: extended;
lastX,lastY,MS: integer;
sqrt2,sqrt3,sqrt5: extended;
begin
MS := MouseSpeed;
sqrt2:= sqrt(2);
sqrt3:= sqrt(3);
sqrt5:= sqrt(5);
while hypot(xs - xe, ys - ye) > 1 do
begin
dist:= hypot(xs - xe, ys - ye);
wind:= minE(wind, dist);
if dist >= targetArea then
begin
windX:= windX / sqrt3 + (random(round(wind) * 2 + 1) - wind) / sqrt5;
windY:= windY / sqrt3 + (random(round(wind) * 2 + 1) - wind) / sqrt5;
end else
begin
windX:= windX / sqrt2;
windY:= windY / sqrt2;
if (maxStep < 3) then
maxStep := (random(3) + 3.0)
else
maxStep := (maxStep/sqrt5);
end;
veloX:= veloX + windX;
veloY:= veloY + windY;
veloX:= veloX + gravity * (xe - xs) / dist;
veloY:= veloY + gravity * (ye - ys) / dist;
if hypot(veloX, veloY) > maxStep then
begin
randomDist:= maxStep / 2.0 + random(round(maxStep) div 2);
veloMag:= sqrt(veloX * veloX + veloY * veloY);
veloX:= (veloX / veloMag) * randomDist;
veloY:= (veloY / veloMag) * randomDist;
end;
lastX:= Round(xs);
lastY:= Round(ys);
xs:= xs + veloX;
ys:= ys + veloY;
case Random(2) of
1: MouseSpeed := (MS+(RandomRange(2,5)));
2: MouseSpeed := (MS-(RandomRange(2,5)));
end;
if (MouseSpeed < 4) then
MouseSpeed := 4;
if (lastX <> Round(xs)) or (lastY <> Round(ys)) then
MoveMouse(Round(xs), Round(ys));
step:= hypot(xs - lastX, ys - lastY);
wait(round((maxWait - minWait) * (step / maxStep) + minWait));
lastdist:= dist;
MouseSpeed := MS;
end;
case Random(2) of
1: MouseSpeed := (MS+(RandomRange(2,5)));
2: MouseSpeed := (MS-(RandomRange(2,5)));
end;
if (MouseSpeed < 4) then
MouseSpeed := 4;
if (Round(xe) <> Round(xs)) or (Round(ye) <> Round(ys)) then
MoveMouse(Round(xe), Round(ye));
MouseSpeed := MS;
end;
{*******************************************************************************
procedure missMouse(Pnt: TPoint; ranX, ranY: Integer);
By: Flight
Description: Makes use of ShiftWindMouse; it also initially misses the target
point (miss area determined by dist & speed) then corrects itself.
*******************************************************************************}
Procedure missMouse(Pnt: TPoint; ranX, ranY: Integer);
var
randSpeed: extended;
X,Y,X2,Y2,A,Dist,MP: integer;
begin
A := MouseSpeed;
getMousePos(X, Y);
Dist := Distance(X, Y, Pnt.X, Pnt.Y);
MP := Round(Dist/150);
if MP < 0 then
MP := 1;
randSpeed := (random(MouseSpeed) / 2.0 + MouseSpeed) / 10.0;
X2 := RandomRange(Pnt.X-(A*MP), Pnt.X+(A*MP));
Y2 := RandomRange(Pnt.Y-(A*MP), Pnt.Y+(A*MP));
shiftWindMouse(X, Y, X2, Y2, 11, 8, 10.0 / randSpeed, 12.0 / randSpeed, 10.0 * randSpeed, 10.0 * randSpeed);
getMousePos(X, Y);
MouseSpeed := round(A*0.7);
if MouseSpeed < 7 then
MouseSpeed := 7;
brakeMMouse(Pnt, ranX, ranY, True);
MouseSpeed := A;
end;
{*******************************************************************************
procedure fastClick(button: Integer);
By: Flight
Description: Quickly click or right-click the mouse.
*******************************************************************************}
procedure fastClick(button: Integer);
var
x, y: integer;
begin
if ((button = MOUSE_MOVE) or (button = -1)) then Exit;
getMousePos(x, y);
holdMouse(x, y, button);
Wait(RandomRange(90, 160));
getMousePos(x, y);
releaseMouse(x, y, button);
end;
(*
DidClick
~~~~~~~~
.. code-block:: pascal
function DidClick(Red: Boolean; Time: integer): boolean;
Checks for the X after a click, Times Out after Time.
DidClick Time must be at LEAST 200 now.
.. note::
by Rasta Magician
Modded by Justin on 1/03/2013
Example:
.. code-block:: pascal
*)
function didClick(Red: Boolean; Time: integer): boolean;
var
T : Timer;
B : TBox;
colR,colG : TColEx;
begin
B := pointToBox(getMousePnt(), 15);
checkAreaBounds(B);
colR.create(255, 15);
colG.create(65535, 15);
T.start();
while (T.timeElapsed < Time) do
begin
if Red then
begin
if (colG.count(B) > 8) then
Exit;
if (colR.count(B) > 10) then
Exit(true);
end else
begin
if (colR.count(B) > 5) then
Exit;
if (colG.count(B) > 35) then
Exit(true);
end;
end;
end;
(*
DidRedClick
~~~~~~~~~~~
.. code-block:: pascal
function didRedClick(): Boolean;
Checks for the Red X after a Click, Times out after 500 ms
.. note::
by Rasta Magician
Example:
.. code-block:: pascal
*)
function didRedClick(): Boolean;
begin
Result := didClick(true, 1000);
end;
(*
DidYellowClick
~~~~~~~~~~~~~~
.. code-block:: pascal
function didYellowClick(): Boolean;
Checks for the Yellow X after a Click, Times out after 500 ms
.. note::
by Rasta Magician
Example:
.. code-block:: pascal
*)
function didYellowClick(): Boolean;
begin
Result := didClick(false, 1000);
end;
procedure mouse(Pnt: TPoint; rX, rY, clickType: Integer);
begin
humanMMouse(Pnt, rX, rY);
wait(randomRange(50,150));
fastClick(clickType);
end;
{*******************************************************************************
procedure mouseBox(x1, y1, x2, y2, Dist, ClickType: Integer);
By: Raymond (modded by Flight)
Description: Does mouse stuff (ClickType), and uses a point that is within Dist from
the closest point between mouse and the box.
*******************************************************************************}
Procedure mouseBox(x1, y1, x2, y2: Integer; Dist, ClickType: Integer);
var
PT : TPoint;
begin
getMousePos(pt.x,pt.y);
PT := randomPointBoxEx(pt,inttobox(x1,y1,x2,y2),Dist);
brakeMMouse(PT, 0, 0, True);
wait(randomRange(100,150));
fastClick(ClickType);
end;
Procedure mouseBox(B: TBox; ClickType: Integer); overload;
var
Pnt : TPoint;
begin
gaussBox(Pnt.x, Pnt.y, B.X1, B.Y1, B.X2, B.Y2);
brakeMMouse(Pnt, 0, 0, True);
wait(randomRange(100,150));
fastClick(ClickType);
end;
(*
GaussMouseBox
~~~~~~~~
.. code-block:: pascal
procedure gaussMouseBox(x1, y1, x2, y2: Integer; ClickType: Integer);
Moves mouse into a random position in the box. Clicks if told to.
.. note::
by Nava2
Example:
.. code-block:: pascal
*)
procedure gaussMouseBox(x1, y1, x2, y2: Integer; ClickType: Integer);
var
fx, fy: Integer;
begin
gaussBox(fx, fy, x1, y1, x2, y2);
if InRange(ClickType, mouse_Right, mouse_move) then
mouse(point(fx,fy), 0, 0, clickType)
else
begin
writeln('[gaussMouseBox] ClickType invalid');
exit;
end;
end;
function mouseInBox(Box: TBox): Boolean;
var
X,Y : Integer;
begin
getMousePos(X, Y);
Result := pointInBox(Point(X, Y), Box);
end;
procedure dragMouseBox(BoxA, BoxB: TBox);
var
x,y : Integer;
begin
if not mouseInBox(BoxA) then
begin
mouseBox(BoxA, MOUSE_MOVE);
Wait(150 + Random(20));
end;
getMousePos(x, y);
HoldMouse(x, y, MOUSE_LEFT);
Wait(250 + Random(320));
mouseBox(BoxB, MOUSE_MOVE);
Wait(250 + Random(120));
getMousePos(x, y);
ReleaseMouse(x, y, MOUSE_LEFT);
end;
procedure mouseCircle(cx, cy, radius, clickType: Integer);
var
rPnt : TPoint;
TPA : TPointArray;
begin
if not InRange(clickType, 0, 3) then
Exit;
TPA := TPAFromEllipse(cx, cy, radius, radius);
if (length(TPA) < 1) then
Exit;
rPnt := TPA[randomRange(0,high(TPA))];
case RandomRange(1,3) of
1: brakeMMouse(rPnt, 0, 0, True);
2: humanMMouse(rPnt, 0, 0);
3: missMouse(rPnt, 0,0);
end;
fastClick(clickType);
end;
Procedure typeByte(B: Byte);
begin
if (B = 13) then
B:= 10;
keyDown(B);
Wait(10 + Random(50));
keyUp(B);
end;
Procedure typeSend(Text: String; Send: Boolean = True);
var
I: Integer;
begin
for I := 1 to Length(Text) do
begin
sendKeys(Text[i], 40+Random(40), 15+Random(30));
Wait(20 + Random(40));
end;
if Send then
begin
{$IFDEF SMART}
typeByte(VK_ENTER);
{$ELSE}
pressKey(VK_ENTER);
{$ENDIF}
end;
end;