SRL Archive - Test corner

My "perfect" procedures


TheGuyWhoGotOn

2007-10-22 21:05:06

I was wondering what people thought of these procedures I made:


procedure PerfectType(message1: string; chance, maxmistakes: integer);
var lengths, number, othernumber: integer;
letter1, letter2: string;
begin
othernumber:= random(chance + 1)
if othernumber < maxmistakes + 1 then
begin
repeat
lengths:= length(message1)
repeat
number:= random(lengths + 1)
until(number > 1)and(number = lengths = false)
letter1:= message1[number]
letter2:= message1[number - 1]
delete(message1, number, 1);
insert(letter2, message1, number);
delete(message1, number - 1, 1);
insert(letter1, message1, number - 1);
othernumber:= othernumber - 1
until(othernumber < 0)
end;
typesend(message1);
end;

Chance is the chance for it to do it decided by maxmistakes for example: chance = 200 and maxmistakes = 5, that means there is a 5 in 200 chance in making at least 1 mistake. Used like:

perfecttype('These are words', 7, 2);


The following is NOT meant to replace "mmouse" or any other mouse procedures, it's just another way of doing it please do not flame me.


procedure PerfectMouseEx(x, y, xran, yran, xshake, yshake, delay, delran: integer; left: boolean);
var xx, yy, xx1, yy1, rand: integer;
begin
getmousepos(xx, yy);
getmousepos(xx1, yy1);
x:= x - xran + random(xran * 2)
y:= y - yran + random(yran * 2)
xx:= xx - x
yy:= yy - y
repeat
if (xx > 0)or(xx = 0) then
begin
rand:= 1 + random(xshake)
xx:= xx - (rand)
xx1:= xx1 - (rand)
end;
if xx < 0 then
begin
rand:= 1 + random(xshake)
xx:= xx + (rand)
xx1:= xx1 + (rand)
end;
if (yy > 0)or(yy = 0) then
begin
rand:= 1 + random(xshake)
yy:= yy - (rand)
yy1:= yy1 - (rand)
end;
if yy < 0 then
begin
rand:= 1 + random(xshake)
yy:= yy + (rand)
yy1:= yy1 + (rand)
end;
movemouse(xx1, yy1);
wait(delay + random(delran));
until((xx = 0)and(yy = 0))
wait(delay * 25 + random(delran * 7));
getmousepos(xx, yy);
holdmouse(xx, yy, left);
wait(31 + random(50));
releasemouse(xx, yy, left);
end;


procedure PerfectMouse(x, y, xran, yran: integer; left: boolean);
var xx, yy, xx1, yy1, rand: integer;
begin
getmousepos(xx, yy);
getmousepos(xx1, yy1);
x:= x - xran + random(xran * 2)
y:= y - yran + random(yran * 2)
xx:= xx - x
yy:= yy - y
repeat
if (xx > 0)or(xx = 0) then
begin
rand:= 1 + random(2)
xx:= xx - (rand)
xx1:= xx1 - (rand)
end;
if xx < 0 then
begin
rand:= 1 + random(2)
xx:= xx + (rand)
xx1:= xx1 + (rand)
end;
if (yy > 0)or(yy = 0) then
begin
rand:= 1 + random(2)
yy:= yy - (rand)
yy1:= yy1 - (rand)
end;
if yy < 0 then
begin
rand:= 1 + random(2)
yy:= yy + (rand)
yy1:= yy1 + (rand)
end;
movemouse(xx1, yy1);
wait(2 + random(2));
until((xx = 0)and(yy = 0))
wait(2 * 25 + random(2 * 7));
getmousepos(xx, yy);
holdmouse(xx, yy, left);
wait(31 + random(50));
releasemouse(xx, yy, left);
end;


procedure PerfectMoveEx(x, y, xran, yran, xshake, yshake, delay, delran: integer);
var xx, yy, xx1, yy1, rand: integer;
begin
getmousepos(xx, yy);
getmousepos(xx1, yy1);
x:= x - xran + random(xran * 2)
y:= y - yran + random(yran * 2)
xx:= xx - x
yy:= yy - y
repeat
if (xx > 0)or(xx = 0) then
begin
rand:= 1 + random(xshake)
xx:= xx - (rand)
xx1:= xx1 - (rand)
end;
if xx < 0 then
begin
rand:= 1 + random(xshake)
xx:= xx + (rand)
xx1:= xx1 + (rand)
end;
if (yy > 0)or(yy = 0) then
begin
rand:= 1 + random(xshake)
yy:= yy - (rand)
yy1:= yy1 - (rand)
end;
if yy < 0 then
begin
rand:= 1 + random(xshake)
yy:= yy + (rand)
yy1:= yy1 + (rand)
end;
movemouse(xx1, yy1);
wait(delay + random(delran));
until((xx = 0)and(yy = 0))
end;


procedure PerfectMove(x, y, xran, yran: integer);
var xx, yy, xx1, yy1, rand: integer;
begin
getmousepos(xx, yy);
getmousepos(xx1, yy1);
x:= x - xran + random(xran * 2)
y:= y - yran + random(yran * 2)
xx:= xx - x
yy:= yy - y
repeat
if (xx > 0)or(xx = 0) then
begin
rand:= 1 + random(2)
xx:= xx - (rand)
xx1:= xx1 - (rand)
end;
if xx < 0 then
begin
rand:= 1 + random(2)
xx:= xx + (rand)
xx1:= xx1 + (rand)
end;
if (yy > 0)or(yy = 0) then
begin
rand:= 1 + random(2)
yy:= yy - (rand)
yy1:= yy1 - (rand)
end;
if yy < 0 then
begin
rand:= 1 + random(2)
yy:= yy + (rand)
yy1:= yy1 + (rand)
end;
movemouse(xx1, yy1);
wait(2 + random(2));
until((xx = 0)and(yy = 0))
end;

Ok let me explain all this, x and y are the coordinates, xran and yran are how random it is where the cursor clicks, xshake and yshake or how shaky the mouse is (I recommend 2), delay is how much of a delay there is per movement, delran is how random the delays are, and left is weather to click the left mouse button or the right mouse button.

Ok, any questions, comments, or suggestions?

Sp0rky

2007-10-22 21:18:04

I'm lovin the perfect type. Maybe it should called 'MistakeType' ? :p

Very human like and realistic.

Havent had a chance to check out perfect mouse yet but, keep up the great work.

TheGuyWhoGotOn

2007-10-22 21:23:01

Lol I guess that would make more sense…I'm just working on more human-like things…maybe HumanType, HumanMouse, ext…

BTW thanks :).

Sp0rky

2007-10-22 21:47:09

Np, some great work.

I'd love to see some kind of typer that makes mistakes (love the chance thing btw) but makes mistypes, ie, hits the key next to the key you're meant to be pressing. THAT would be impressive.

TheGuyWhoGotOn

2007-10-26 18:32:40

From: Sp0rky
Np, some great work.

I'd love to see some kind of typer that makes mistakes (love the chance thing btw) but makes mistypes, ie, hits the key next to the key you're meant to be pressing. THAT would be impressive.


I thought about that…However I never do that I just swap a few things sometimes so I don't really want to spend the time into it.

King of Knives

2007-10-27 05:59:03

I made something that pressed the key next to the right one, and then corrected it. I used this function which took some time to make.

It isn't perfect, 'cause I'm Danish, and I'm now sure how the american/canadian keyboards look like.
Anyways, here it is, free to use if you credit, etc…
Function GetNeighbourKey(S: String; DanishKB: Boolean): String;
var B: Boolean;
begin
if Uppercase(S) = S then B:= True;
begin
B:= False;
end;
If(Length(S) > 1)then
begin
Writeln('GetNeighbourKey problem: Only supports 1 letter at a time')
end;
S:= LowerCase(S)
if(S = 'Æ')then
begin
S:= 'æ'
end;
if(S = 'Ø')then
begin
S:= 'ø'
end;
if(S = 'Å')then
begin
S:= 'å'
end;
if(GetLetters(S) = '')then
begin
Result:= S;
end;
case S of
'a': begin
case Random(5) of
0: Result:= 'q'
1: Result:= 'w'
2: Result:= 's'
3: Result:= 'z'
5: Result:= '<'
end;
end;

'b': begin
case Random(5) of
0: Result:= 'v'
1: Result:= 'g'
2: Result:= 'h'
3: Result:= 'n'
4: Result:= ' '
end;
end;

'c': begin
case Random(5) of
0: Result:= 'x'
1: Result:= 'd'
2: Result:= 'f'
3: Result:= 'v'
4: Result:= ' '
end;
end;

'd': begin
case Random(6) of
0: Result:= 's'
1: Result:= 'e'
2: Result:= 'r'
3: Result:= 'f'
4: Result:= 'c'
5: Result:= 'x'
end;
end;

'e': begin
case Random(6) of
0: Result:= 'w'
1: Result:= 's'
2: Result:= 'd'
3: Result:= 'r'
4: Result:= '3'
5: Result:= '4'
end;
end;

'f': begin
case Random(6) of
0: Result:= 'd'
1: Result:= 'r'
2: Result:= 't'
3: Result:= 'g'
4: Result:= 'v'
5: Result:= 'c'
end;
end;

'g': begin
case Random(6) of
0: Result:= 'f'
1: Result:= 't'
2: Result:= 'y'
3: Result:= 'h'
4: Result:= 'b'
5: Result:= 'v'
end;
end;

'h': begin
case Random(6) of
0: Result:= 'g'
1: Result:= 'y'
2: Result:= 'u'
3: Result:= 'j'
4: Result:= 'n'
5: Result:= 'b'
end;
end;

'i': begin
case Random(6) of
0: Result:= 'u'
1: Result:= 'j'
2: Result:= 'k'
3: Result:= 'o'
4: Result:= '8'
5: Result:= '9'
end;
end;

'j': begin
case Random(6) of
0: Result:= 'h'
1: Result:= 'u'
2: Result:= 'i'
3: Result:= 'k'
4: Result:= 'm'
5: Result:= 'n'
end;
end;

'k': begin
case Random(6) of
0: Result:= 'm'
1: Result:= 'j'
2: Result:= 'i'
3: Result:= 'o'
4: Result:= 'l'
5: Result:= ','
end;
end;

'l': begin
case Random(5) of
0: Result:= 'k'
1: Result:= 'o'
2: Result:= 'p'
3: Result:= '.'
4: if DanishKB then
begin
Result:= 'æ'
end else
case Random(4) of
0: Result:= 'k'
1: Result:= 'o'
2: Result:= 'p'
3: Result:= '.'
end;
end;
end;

'm': begin
case Random(5) of
0: Result:= 'n'
1: Result:= 'j'
2: Result:= 'k'
3: Result:= ','
4: Result:= ' '
end;
end;

'n': begin
case Random(5) of
0: Result:= 'b'
1: Result:= 'h'
2: Result:= 'j'
3: Result:= 'm'
4: Result:= ' '
end;
end;

'o': begin
case Random(6) of
0: Result:= 'i'
1: Result:= 'k'
2: Result:= 'l'
3: Result:= 'p'
4: Result:= '9'
5: Result:= '0'
end;
end;

'p': begin
case Random(6) of
0: Result:= 'o'
1: Result:= 'l'
2: Result:= '0'
3: Result:= '+'
4: if DanishKB then
begin
Result:= 'æ'
end else
case Random(4) of
0: Result:= 'o'
1: Result:= 'l'
2: Result:= '0'
3: Result:= '+'
end;
5: if DanishKB then
begin
Result:= 'ø'
end else
case Random(4) of
0: Result:= 'o'
1: Result:= 'l'
2: Result:= '0'
3: Result:= '+'
end;
end;
end;

'q': begin
case Random(5) of
0: Result:= 'a'
1: Result:= 's'
2: Result:= 'w'
3: Result:= '1'
4: Result:= '2'
end;
end;

'r': begin
case Random(6) of
0: Result:= 'e'
1: Result:= 'd'
2: Result:= 'f'
3: Result:= 't'
4: Result:= '4'
5: Result:= '5'
end;
end;

's': begin
case Random(3) of
0: Result:= 'a'
1: Result:= 'w'
2: Result:= 'e'
3: Result:= 'd'
4: Result:= 'x'
5: Result:= 'z'
end;
end;

't': begin
case Random(6) of
0: Result:= 'r'
1: Result:= 'f'
2: Result:= 'g'
3: Result:= 'y'
4: Result:= '5'
5: Result:= '6'
end;
end;

'u': begin
case Random(6) of
0: Result:= 'y'
1: Result:= 'h'
2: Result:= 'j'
3: Result:= 'i'
4: Result:= '7'
5: Result:= '8'
end;
end;

'v': begin
case Random(5) of
0: Result:= 'c'
1: Result:= 'f'
2: Result:= 'g'
3: Result:= 'b'
4: Result:= ' '
end;
end;

'w': begin
case Random(6) of
0: Result:= 'q'
1: Result:= 'a'
2: Result:= 's'
3: Result:= 'e'
4: Result:= '2'
5: Result:= '3'
end;
end;

'x': begin
case Random(4) of
0: Result:= 'z'
1: Result:= 's'
2: Result:= 'd'
3: Result:= 'c'
end;
end;

'y': begin
case Random(6) of
0: Result:= 't'
1: Result:= 'g'
2: Result:= 'h'
3: Result:= 'u'
4: Result:= '6'
5: Result:= '7'
end;
end;

'z': begin
case Random(4) of
0: Result:= 'a'
1: Result:= 's'
2: Result:= 'x'
3: Result:= '<'
end;
end;
end;
if DanishKB then
begin
Case S of

'æ': begin
Case Random(6) of
0: Result:= 'l'
1: Result:= '.'
2: Result:= '-'
3: Result:= 'ø'
4: Result:= 'å'
5: Result:= 'p'
end;
end;

'ø': begin
case Random(4) of
0: Result:= 'æ'
1: Result:= '-'
2: Result:= ''''
3: Result:= 'å'
end;
end;

'å': begin
case Random(4) of
0: Result:= '+'
1: Result:= 'p'
2: Result:= 'æ'
3: Result:= 'ø'
end;
end;
end;
end;
If(B)then
begin
Result:= Uppercase(Result)
if(Result = 'æ')then
begin
Result:= 'Æ'
end;
if(Result = 'ø')then
begin
Result:= 'Ø'
end;
if(Result = 'å')then
begin
Result:= 'Å'
end;
end;
end;

Anyways, you know I like your procedure TGWGO, so I don't really have to comment :D

-Knives

mastaraymond

2007-10-27 06:41:26

From: King of Knives
I made something that pressed the key next to the right one, and then corrected it. I used this function which took some time to make.

It isn't perfect, 'cause I'm Danish, and I'm now sure how the american/canadian keyboards look like.
Anyways, here it is, free to use if you credit, etc…

Anyways, you know I like your procedure TGWGO, so I don't really have to comment :D

-Knives

Nice one, but why don't you make something like this:
Line[1] := 'qwertyuiop[]\'
Line[2] := 'asdfghjkl;'
Line[3] := 'zxcvbnm,./'

Then you can work with numbers, instead of using chars ;). Ok, its a bit harder, but it will be loads shorter ^^

~Raymond

King of Knives

2007-10-27 06:47:20

I didn't think of it when I made that. Which is like, 2-3 months ago…

-Knives

TheGuyWhoGotOn

2007-10-27 08:47:40

From: King of Knives
I made something that pressed the key next to the right one, and then corrected it. I used this function which took some time to make.

It isn't perfect, 'cause I'm Danish, and I'm now sure how the american/canadian keyboards look like.
Anyways, here it is, free to use if you credit, etc…
Function GetNeighbourKey(S: String; DanishKB: Boolean): String;
var B: Boolean;
begin
if Uppercase(S) = S then B:= True;
begin
B:= False;
end;
If(Length(S) > 1)then
begin
Writeln('GetNeighbourKey problem: Only supports 1 letter at a time')
end;
S:= LowerCase(S)
if(S = 'Æ')then
begin
S:= 'æ'
end;
if(S = 'Ø')then
begin
S:= 'ø'
end;
if(S = 'Å')then
begin
S:= 'å'
end;
if(GetLetters(S) = '')then
begin
Result:= S;
end;
case S of
'a': begin
case Random(5) of
0: Result:= 'q'
1: Result:= 'w'
2: Result:= 's'
3: Result:= 'z'
5: Result:= '<'
end;
end;

'b': begin
case Random(5) of
0: Result:= 'v'
1: Result:= 'g'
2: Result:= 'h'
3: Result:= 'n'
4: Result:= ' '
end;
end;

'c': begin
case Random(5) of
0: Result:= 'x'
1: Result:= 'd'
2: Result:= 'f'
3: Result:= 'v'
4: Result:= ' '
end;
end;

'd': begin
case Random(6) of
0: Result:= 's'
1: Result:= 'e'
2: Result:= 'r'
3: Result:= 'f'
4: Result:= 'c'
5: Result:= 'x'
end;
end;

'e': begin
case Random(6) of
0: Result:= 'w'
1: Result:= 's'
2: Result:= 'd'
3: Result:= 'r'
4: Result:= '3'
5: Result:= '4'
end;
end;

'f': begin
case Random(6) of
0: Result:= 'd'
1: Result:= 'r'
2: Result:= 't'
3: Result:= 'g'
4: Result:= 'v'
5: Result:= 'c'
end;
end;

'g': begin
case Random(6) of
0: Result:= 'f'
1: Result:= 't'
2: Result:= 'y'
3: Result:= 'h'
4: Result:= 'b'
5: Result:= 'v'
end;
end;

'h': begin
case Random(6) of
0: Result:= 'g'
1: Result:= 'y'
2: Result:= 'u'
3: Result:= 'j'
4: Result:= 'n'
5: Result:= 'b'
end;
end;

'i': begin
case Random(6) of
0: Result:= 'u'
1: Result:= 'j'
2: Result:= 'k'
3: Result:= 'o'
4: Result:= '8'
5: Result:= '9'
end;
end;

'j': begin
case Random(6) of
0: Result:= 'h'
1: Result:= 'u'
2: Result:= 'i'
3: Result:= 'k'
4: Result:= 'm'
5: Result:= 'n'
end;
end;

'k': begin
case Random(6) of
0: Result:= 'm'
1: Result:= 'j'
2: Result:= 'i'
3: Result:= 'o'
4: Result:= 'l'
5: Result:= ','
end;
end;

'l': begin
case Random(5) of
0: Result:= 'k'
1: Result:= 'o'
2: Result:= 'p'
3: Result:= '.'
4: if DanishKB then
begin
Result:= 'æ'
end else
case Random(4) of
0: Result:= 'k'
1: Result:= 'o'
2: Result:= 'p'
3: Result:= '.'
end;
end;
end;

'm': begin
case Random(5) of
0: Result:= 'n'
1: Result:= 'j'
2: Result:= 'k'
3: Result:= ','
4: Result:= ' '
end;
end;

'n': begin
case Random(5) of
0: Result:= 'b'
1: Result:= 'h'
2: Result:= 'j'
3: Result:= 'm'
4: Result:= ' '
end;
end;

'o': begin
case Random(6) of
0: Result:= 'i'
1: Result:= 'k'
2: Result:= 'l'
3: Result:= 'p'
4: Result:= '9'
5: Result:= '0'
end;
end;

'p': begin
case Random(6) of
0: Result:= 'o'
1: Result:= 'l'
2: Result:= '0'
3: Result:= '+'
4: if DanishKB then
begin
Result:= 'æ'
end else
case Random(4) of
0: Result:= 'o'
1: Result:= 'l'
2: Result:= '0'
3: Result:= '+'
end;
5: if DanishKB then
begin
Result:= 'ø'
end else
case Random(4) of
0: Result:= 'o'
1: Result:= 'l'
2: Result:= '0'
3: Result:= '+'
end;
end;
end;

'q': begin
case Random(5) of
0: Result:= 'a'
1: Result:= 's'
2: Result:= 'w'
3: Result:= '1'
4: Result:= '2'
end;
end;

'r': begin
case Random(6) of
0: Result:= 'e'
1: Result:= 'd'
2: Result:= 'f'
3: Result:= 't'
4: Result:= '4'
5: Result:= '5'
end;
end;

's': begin
case Random(3) of
0: Result:= 'a'
1: Result:= 'w'
2: Result:= 'e'
3: Result:= 'd'
4: Result:= 'x'
5: Result:= 'z'
end;
end;

't': begin
case Random(6) of
0: Result:= 'r'
1: Result:= 'f'
2: Result:= 'g'
3: Result:= 'y'
4: Result:= '5'
5: Result:= '6'
end;
end;

'u': begin
case Random(6) of
0: Result:= 'y'
1: Result:= 'h'
2: Result:= 'j'
3: Result:= 'i'
4: Result:= '7'
5: Result:= '8'
end;
end;

'v': begin
case Random(5) of
0: Result:= 'c'
1: Result:= 'f'
2: Result:= 'g'
3: Result:= 'b'
4: Result:= ' '
end;
end;

'w': begin
case Random(6) of
0: Result:= 'q'
1: Result:= 'a'
2: Result:= 's'
3: Result:= 'e'
4: Result:= '2'
5: Result:= '3'
end;
end;

'x': begin
case Random(4) of
0: Result:= 'z'
1: Result:= 's'
2: Result:= 'd'
3: Result:= 'c'
end;
end;

'y': begin
case Random(6) of
0: Result:= 't'
1: Result:= 'g'
2: Result:= 'h'
3: Result:= 'u'
4: Result:= '6'
5: Result:= '7'
end;
end;

'z': begin
case Random(4) of
0: Result:= 'a'
1: Result:= 's'
2: Result:= 'x'
3: Result:= '<'
end;
end;
end;
if DanishKB then
begin
Case S of

'æ': begin
Case Random(6) of
0: Result:= 'l'
1: Result:= '.'
2: Result:= '-'
3: Result:= 'ø'
4: Result:= 'å'
5: Result:= 'p'
end;
end;

'ø': begin
case Random(4) of
0: Result:= 'æ'
1: Result:= '-'
2: Result:= ''''
3: Result:= 'å'
end;
end;

'å': begin
case Random(4) of
0: Result:= '+'
1: Result:= 'p'
2: Result:= 'æ'
3: Result:= 'ø'
end;
end;
end;
end;
If(B)then
begin
Result:= Uppercase(Result)
if(Result = 'æ')then
begin
Result:= 'Æ'
end;
if(Result = 'ø')then
begin
Result:= 'Ø'
end;
if(Result = 'å')then
begin
Result:= 'Å'
end;
end;
end;

Anyways, you know I like your procedure TGWGO, so I don't really have to comment :D

-Knives


Nice Knives but couldn't you make it more than one letter at a time? Oh nevermind I see how it works now…That's pretty cool, it could be used in some auto typers for sure.

King of Knives

2007-10-27 14:51:13

You can take it for PH, if you wish :D

-Knives

TheGuyWhoGotOn

2007-10-31 07:50:13

From: King of Knives
You can take it for PH, if you wish :D

-Knives


I may do that :), thanks! I just need to get everything organized for it again…Make it compatible with SRL ;).

Edit: I'll add it to the next release :) I'm just going to make it compatible with SRL