SCAR Code:
program test;
const
time_out = 2500;
mousespeed = 9;
UserControl = 2; // 0 for disabled, 1 for a wait, 2 for ghost mouse
var
mouse_x, mouse_y, mx, my, freeze: integer;
cursor: integer;
procedure WaitForAFK();
var tx,ty,timer:integer;
begin
repeat
GetMousePos(mx,my);
if (tx = mx) and (ty = my) then
begin
timer := timer + 250;
end else
begin
tx := mx;
ty := my;
timer := 0;
end;
Wait(250);
until (timer >= time_out);
end;
function within(a,b,c:integer):boolean;
begin
result := true;
if a > b then
begin
a := a - c;
if a > b then
result := false;
end else
begin
a := a + c;
if a < b then
result := false;
end;
end;
procedure WaitForReturn();
var done:boolean;
begin
done := false;
wait(200);
repeat
SafeDrawBitmap(cursor, GetClientCanvas, mouse_x, mouse_y);
GetMousePos(mx,my);
if within(mouse_x,mx,10) and within(mouse_y,my,10) then
begin
done := true;
freeze := GetTimeRunning() + 500;
end;
wait(100);
until done
end;
function MM(x,y:integer):boolean;
begin
GetMousePos(mx,my);
if ((mouse_x <> mx) or (mouse_y <> my)) and (GetTimeRunning() >= freeze) then
begin
case usercontrol of
1: WaitForAFK;
2: WaitForReturn;
end;
mouse_x := mx;
mouse_y := my;
result := true;
end else
begin
MoveMouse(x,y);
mouse_x := x;
mouse_y := y;
result := false;
end;
end;
procedure WindMouse(xs, ys, xe, ye, gravity, wind, minWait, maxWait, maxStep, targetArea: extended);
var
veloX, veloY, windX, windY, veloMag, dist, randomDist, lastDist, step: extended;
lastX, lastY: integer;
sqrt2, sqrt3, sqrt5: extended;
begin
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
begin
maxStep:= random(3) + 3.0;
end else
begin
maxStep:= maxStep / sqrt5;
end;
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) / 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
if MM(Round(xs), Round(ys)) then
begin
xs := mx;
ys := my;
end;
step:= hypot(xs - lastX, ys - lastY);
wait(round((maxWait - minWait) * (step / maxStep) + minWait));
lastdist:= dist;
end;
if (Round(xe) <> Round(xs)) or (Round(ye) <> Round(ys)) then
if MM(Round(xe), Round(ye)) then
begin
xs := mx;
ys := my;
end;
end;
procedure MMouse(x, y, rx, ry: integer);
var
cx, cy: integer;
randSpeed: Extended;
begin
GetMousePos(cx, cy);
randSpeed:= (random(MouseSpeed) / 2.0 + MouseSpeed) / 10.0;
if randSpeed = 0.0 then
randSpeed := 0.1;
X := x + random(rx);
Y := y + random(ry);
WindMouse(cx,cy,x,y,9.0,3.0,10.0/randSpeed,15.0/randSpeed,10.0*randSpeed,10.0*randSpeed);
end;
procedure Mouse(mousex, mousey, ranx, rany: Integer; left: Boolean);
var
a, b, c: Integer;
begin
MMouse(mousex, mousey, ranx, rany);
Wait(60 + Random(30));
GetMousePos(b, c);
HoldMouse(b, c, left);
repeat
Wait(20 + Random(30));
a := a + 1;
until (a > 4);
GetMousePos(b, c);
ReleaseMouse(b, c, left);
Wait(100 + Random(100));
end;
procedure mouseinit();
begin
GetMousePos(mouse_x,mouse_y);
cursor := BitmapFromString(12, 20, 'beNqd0tERgCAIBuB/WnZwrm' +
'bp0VlIuKPACCuP80E/ORSJwIzeUQ/mbcw145EIC6Zmr5mZiqlZsGh' +
'yZqZimZmZM48sM7Llw5nzHWSd6Aoz0rjJxJoFtCaRtkaPy268Qkjl' +
'wccu872qvx/mTSrojXEANM+t0g==');
end;
begin
mouseinit;
Mouse(1000,900,5,5,true);
end.
SCAR Code:
program Zzz;
var keyboard, shiftboard, current: array [0..3] of string;
mistypeprobability:integer;
lastletter:string;
{ Things that are not finished:
~Adding capitalization of letters
}
procedure KeyboardVars;
begin
keyboard[0] := '`1234567890-= '; shiftboard[0] := '~!@#$%^&*()_+' ;
keyboard[1] := ' qwertyuiop[]\'; shiftboard[1] := ' QWERTYUIOP{}|';
keyboard[2] := ' asdfghjkl;''' ; shiftboard[2] := ' ASDFGHJKL:"' ;
keyboard[3] := ' zxcvbnm,./' ; shiftboard[3] := ' ZXCVBNM<>?' ;
end;
procedure Letter(character:char);
var key:byte;
begin
key := GetKeyCode(character);
Wait(random(10));
KeyDown(key);
Wait(20+Random(40));
KeyUp(key);
Wait(random(10));
end;
procedure PressEnter();
begin
Letter(Chr(13));
end;
procedure PressBack();
begin
Letter(Chr(8));
end;
function TypeLetter(character:char; mistake:boolean):integer;
var normal, shift:string;
i, position, positioni:integer;
key:char;
begin
result := 0;
if character = ' ' then
begin
Letter(' ');
Exit;
end;
normal := '`1234567890-=qwertyuiop[]\asdfghjkl;''zxcvbnm,./';
shift := '~!@#$%^&*()_+QWERTYUIOP}{|ASDFGHJKL:"ZXCVBNM<>?' ;
if Pos(character, normal) <> 0 then
current := keyboard;
if Pos(character, shift) <> 0 then
current := shiftboard;
for i := 0 to 3 do
begin
if Pos(character, current[i]) <> 0 then
positioni := i;
end;
position := Pos(character, current[positioni]);
key := current[positioni][position];
if mistake then
begin
case Random(120 + mistypeprobability) of
0..2: // Longer wait, ex. forget key location or something
begin
Wait(30+Random(100));
mistypeprobability := mistypeprobability + 10;
end;
3..15: // Shorter wait, ex. small brainfart
begin
Wait(Random(40));
mistypeprobability := mistypeprobability + 5;
end;
16: // No letter typed
begin
result := 1;
Exit;
end;
17..20: // Chance to mistype letter on the same row
begin
position := position - 1 + Random(3);
if position < 1 then
position := 1;
if (positioni > 0) and (position < 2) then
position := 2;
if position > Length(current[positioni]) then
position := Length(current[positioni]);
if key <> current[positioni][position] then
begin
key := current[positioni][position];
result := 2;
mistypeprobability := mistypeprobability + 25;
end;
end;
21: // Mistype the letter upward
begin
positioni := positioni + 1;
if positioni > 3 then
positioni := 3;
if key <> current[positioni][position] then
begin
key := current[positioni][position];
result := 2;
mistypeprobability := mistypeprobability + 25;
end;
end;
22: // Mistype the letter downward
begin
positioni := positioni - 1;
if positioni < 0 then
positioni := 0;
if key <> current[positioni][position] then
begin
key := current[positioni][position];
result := 2;
mistypeprobability := mistypeprobability + 25;
end;
end;
23..300: // No mistype, increase the chance to mistype for the next letter
begin
mistypeprobability := mistypeprobability - 1;
end;
end;
end;
Letter(key);
end;
procedure TypeText(text:string;mistake,fix:boolean);
var i,n,t,b:integer;
begin
i := 1;
n := 0;
b := 0;
mistypeprobability := 100;
while (i <= Length(text)) do
begin
if fix then
begin
if b = 0 then
begin
b := TypeLetter(text[i],mistake);
if b <> 0 then
n := i;
end else
TypeLetter(text[i],mistake);
if ((random(6) = 5) and (b <> 0)) or ((Length(text) - i < 2) and (b <> 0)) then
begin
Wait(99+Random(300));
if b = 2 then
begin
Wait(15+Random(45));
PressBack;
end;
for t := 1 to (i - n) do
begin
Wait(15+Random(45));
PressBack;
end;
i := n - 1;
b := 0;
end;
end else
begin
TypeLetter(text[i],mistake);
end;
i := i + 1;
Wait(20+Random(40));
end;
end;
begin
KeyboardVars;
TypeText('Harry was a small litte boy, he had no brains but was a very happy child, other children were very envious of his happiness so they went to a witch doctor with horrible intentions.',true,true);
end.