SRL Archive - SRL Archives

TypeSendEx


Shuttleu

2009-06-25 03:03:27

this is shorter and from what i can see it should still work just as well
{*******************************************************************************
procedure TypeSendEx(Text: string; PressEnter: Boolean);
By: Shuttleu
Description: Sends human like text.
*******************************************************************************}
procedure TypeSendEx(Text: string; PressEnter: Boolean);
var
I: Integer;
Char: Byte;
ThisOne, NextOne, LastOne: Boolean;
begin
for I:=1 to Length(Text) do
begin
ThisOne:= (Uppercase(Text[I]) = Text[I]);
if (not(I = Length(Text))) then
NextOne:= (Uppercase(Text[I+1]) = Text[I+1]);
if (not(I = 1)) then
LastOne:= (Uppercase(Text[I-1]) = Text[I-1]);
Char := GetKeyCode(Text[i]);
if ((not(LastOne)) and (ThisOne)) then
begin
KeyDown(VK_SHIFT);
Wait(40 + Random(40));
end;
TypeByte(Char);
Wait(40 + Random(40));
if (not(NextOne))or(I = Length(Text)) then
begin
KeyUp(VK_SHIFT);
Wait(40 + Random(40));
end;
end;
if (not(PressEnter)) then Exit;
Char := GetKeyCode(Chr(13));
TypeByte(Char);
end;

~shut

EDIT: also while looking through the current TypeSendEx it doesnt wait between typing capitals

Macro_FTW

2009-06-25 03:05:48

Good idea. I support it. :p

Naike

2009-06-25 03:34:54

Note: Not fair to call the whole function yours, after just shortening it.

Got an "Closing parenthesis expected in script", fixed it.. Look under

{*******************************************************************************
procedure TypeSendEx(Text: string; PressEnter: Boolean);
By: Shuttleu
Description: Sends human like text.
*******************************************************************************}
procedure TypeSendEx(Text: string; PressEnter: Boolean);
var
S: string;
I: Integer;
D: Byte;
A, B, C: Boolean;
begin
S:= 'ABCDEFGHIJKLMNOPQRSTUVWXZ' + '~!@#$%^&*()_+{}|:"<>?';
for I:=0 to Length(Text) do
begin
A:= (Pos(Text[i], S) > 0);
if (not(I = Length(Text))) then
B:= (Pos(Text[I+1], S) > 0);
if (not(I = 0)) then
C:= (Pos(Text[I-1], S) > 0);
D := GetKeyCode(Text[i]);
if ((not(C)) and (A)) then
begin
KeyDown(VK_SHIFT);
Wait(40 + Random(40));
end;
TypeByte(D);
Wait(40 + Random(40));
if (not(B))or(I = Length(Text)) then // This line had the error.
begin
KeyUp(VK_SHIFT);
Wait(40 + Random(40));
end;
end;
if (not(PressEnter)) then Exit;
D := GetKeyCode(Chr(13));
TypeByte(D);
end;


Than I tested the function with this
Note: The slight name change is to get rid of errors..

program New;
{.include SRL/SRL.scar}

{*******************************************************************************
procedure TypeSendEx(Text: string; PressEnter: Boolean);
By: Shuttleu
Description: Sends human like text.
*******************************************************************************}
procedure n_TypeSendEx(Text: string; PressEnter: Boolean);
var
S: string;
I: Integer;
D: Byte;
A, B, C: Boolean;
begin
S:= 'ABCDEFGHIJKLMNOPQRSTUVWXZ' + '~!@#$%^&*()_+{}|:"<>?';
for I:=0 to Length(Text) do
begin
A:= (Pos(Text[i], S) > 0);
if (not(I = Length(Text))) then
B:= (Pos(Text[I+1], S) > 0);
if (not(I = 0)) then
C:= (Pos(Text[I-1], S) > 0);
D := GetKeyCode(Text[i]);
if ((not(C)) and (A)) then
begin
KeyDown(VK_SHIFT);
Wait(40 + Random(40));
end;
TypeByte(D);
Wait(40 + Random(40));
if (not(B))or(I = Length(Text)) then
begin
KeyUp(VK_SHIFT);
Wait(40 + Random(40));
end;
end;
if (not(PressEnter)) then Exit;
D := GetKeyCode(Chr(13));
TypeByte(D);
end;

begin
SetupSRL;
Wait(2000);
n_TypeSendEx('abcdefghijlgmnlopqrstouwz', False);
end.

But I got "[Runtime Error] : Out of string range in line 19 in script" while running it.

Sorry for being such a killer..

Shuttleu

2009-06-25 03:41:36

From: N1ke!
Looking at it…
Will edit when done…

Note: Not fair to call the whole function yours, after just shortening it.


i rewrote the whole thing from scratch in a bog standard text editor

~shut

ZephyrsFury

2009-06-25 03:48:07

Chars in a string start at index 1. So it should be for I := 1 to Length(string) do

Shuttleu

2009-06-25 03:50:49

From: ZephyrsFury
Chars in a string start at index 1. So it should be for I := 1 to Length(string) do


oh i thought they started at 0 which wil explain N1kes!'s error

~shut

Da 0wner

2009-06-25 05:32:21

You can do:
if uppercase(text[i]) = text[i] then
//it's uppercase

Shuttleu

2009-06-25 11:18:33

From: Da 0wner
You can do:
if uppercase(text[i]) = text[i] then
//it's uppercase

i dont think that
~!@#$%^&*()_+{}|:"<>?
would comeup as uppercase text

~shut

Da 0wner

2009-06-25 11:23:35

It does. I have my own TypeSend function which is shorter than yours.

Shuttleu

2009-06-25 11:41:50

edited

~shut

Da 0wner

2009-06-25 12:08:56

:). I'll post mine in a few days. However I am grounded so cannot go on any computer.

Shuttleu

2009-06-25 12:18:58

so how are you posting?

~shut

ian.

2009-06-25 12:51:22

iTouch/iPhone.. one of those two.

Da 0wner

2009-06-25 13:14:50

Yep, 99_ is right, <3 :p.

ZephyrsFury

2009-06-25 17:22:07

How is this better than the current one though? I don't wanna fix something that isn't broken but might introduce more bugs.

Da 0wner

2009-06-25 17:30:26

Zeph, stay on for 2 or 3 hours and I will sneak on to post mine. Then you can commit it. I assure you that it is flawless :p.

Naum

2009-06-25 19:10:13

{*******************************************************************************
procedure iType(Text : string; WaitTime : integer; Return : boolean);
By: Da 0wner
Description: Types text...
*******************************************************************************}

procedure iType(Text : string; WaitTime : integer; Return : boolean);
var
i: integer;
s : string;
begin
s := '~!@#$%^&*()_+ABCDEFGHIJKLMNOPQRSTUVWXYZ{}|:"<>?';
for i := 1 to Length(Text) do
begin
if pos(Text[i], s) > 0 then
begin
KeyDown(VK_SHIFT);
Wait(WaitTime + Random(40));
end;
KeyDown(GetKeyCode(Text[i]));
Wait(WaitTime + Random(30));
KeyUp(GetKeyCode(Text[i]));
Wait(WaitTime + Random(30));
if pos(Text[i], s) > 0 then
KeyUp(VK_SHIFT);
end;
if not Return then
exit;
Wait(10 + Random(30));
KeyDown(VK_RETURN);
Wait(10 + Random(30));
KeyUp(VK_RETURN);
end;

?

Quickmarch

2009-06-25 19:16:27

From: Da 0wner
Zeph, stay on for 2 or 3 hours and I will sneak on to post mine. Then you can commit it. I assure you that it is flawless :p.


Da 0wner, your's and Shuttleu's are four lines different…

ZephyrsFury

2009-06-25 19:23:11

From: Da 0wner
Zeph, stay on for 2 or 3 hours and I will sneak on to post mine. Then you can commit it. I assure you that it is flawless :p.


I'm not commiting stuff for no reason. =/

Sir R. M8gic1an

2009-06-25 19:35:02

if it's not broken, don't fix it.

~RM

Shuttleu

2009-06-26 01:30:03

From: Rasta Magician
if it's not broken, don't fix it.

~RM


in the current one when typing more than one uppercase letter at a time it doesn't wait before typing them

~shut

ZephyrsFury

2009-06-26 05:20:27

From: Shuttleu
in the current one when typing more than one uppercase letter at a time it doesn't wait before typing them

~shut


Can we not just add a wait to the current function then:


procedure TypeSendEx(Text: string; PressEnter: Boolean);
var
S: string;
I, L: Integer;
C: Byte;
Shift: Boolean;
begin
S:= 'ABCDEFGHIJKLMNOPQRSTUVWXZ' + '~!@#$%^&*()_+{}|:"<>?';
L := Length(Text);
for I:= 1 to L do
begin
Shift:= (Pos(Text[i], S) > 0);
if(Shift)then
begin
KeyDown(VK_SHIFT) Wait(40 + Random(40));
while(Pos(Text[i], S) > 0)and(I <= Length(Text))do
begin
C := GetKeyCode(StrGet(Text, I));
TypeByte(c);
Wait(40 + Random(40)); //Here?
I:= I + 1;
if(I > Length(Text))then Break;
end;
end;
if(Shift)then
KeyUp(VK_SHIFT);
Wait(40 + Random(40));
if(I <= Length(Text))then
begin
C:= GetKeyCode(StrGet(Text, I));
TypeByte(C);
Wait(40 + Random(40));
end;
end;
If Not PressEnter Then Exit;
C := GetKeyCode(Chr(13));
TypeByte(C);
end;

Da 0wner

2009-06-26 08:49:32

From: Quickmarch
Da 0wner, your's and Shuttleu's are four lines different…

That's an outdated function, Naum posted it :p.