SRL Archive - SRL Archives

[EDIT] TypeSendEx - User variables


Rich

2010-12-30 09:30:32

Some people were saying that SRL types too fast, so I decided to edit TypeSendEx. It works like MMouse where the user changes the speed in the script with a variable (two in this case). If the speed is too fast or slow, the script sets the default used at the moment.

Add two variables in text.simba
- KeySpeed
- RandKeySpeed

These are the variables which will be set like MouseSpeed.

var
OldLine, TheLine, TheName: string;
KeySpeed, RandKeySpeed : Integer;

{ const clMessage, clChat, clTrade, clFriend
Description: Text colour constants. }
const
clMessage = clBlack;
clChat = clBlue;
clTrade = clPurple;
clFriend = 128;

//CODE CUT

{*******************************************************************************
procedure TypeSendEx(Text: string; PressEnter: Boolean);
By: SKy Scripter
Description: Sends human like text.
*******************************************************************************}
procedure TypeSendEx(Text: string; PressEnter: Boolean);
var
S: string;
I, L: Integer;
Shift: Boolean;
begin
if not InRange(KeySpeed, 20, 80) then
KeySpeed = 40;
if not InRange(RandKeySpeed, 20, 80) then
RandKeySpeed = 40;
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(KeySpeed + Random(RandKeySpeed));
while (Pos(Text[i], S) > 0) and (I <= Length(Text)) do
begin
TypeByte(GetKeyCode(Text[I]));
Wait(KeySpeed + Random(RandKeySpeed));
Inc(I);
if (I > Length(Text)) then Break;
end;
end;
if (Shift) then
KeyUp(VK_SHIFT);
Wait(KeySpeed + Random(RandKeySpeed));
if (I <= Length(Text)) then
begin
TypeByte(GetKeyCode(Text[I]));
Wait(KeySpeed + Random(RandKeySpeed));
end;
end;
if (PressEnter) then
TypeByte(GetKeyCode(Chr(13)));
end;

Usage example:
program New;
{.include SRL/SRL.simba}

begin
SetupSRL;
MouseSpeed:= 10;
KeySpeed:= 50;
RandKeySpeed:= 45;
EverythingElse;
end.
Comments?

Gu3st...

2010-12-30 10:05:08

Rename to KeySpeed and RandomKeySpeed perhaps? I just feel like that would make more sense.. Other than that; I love it

Rich

2010-12-30 10:11:22

^ But MS shows it's in milliseconds. I'll just leave it for the Devs to decide on that.

ZephyrsFury

2010-12-30 10:28:04

Maybe have RandKeyMS calculated as a percentage of KeyMS so that you only need to set one variable. Good idea though. :D

Rich

2010-12-30 10:32:51

Well the current way it's used is that the randomness is the same as the original wait, so maybe just do that?

Nava2

2010-12-30 10:37:48

I think this should be done when we do the grand verhaul for personalization amongst the include. For now, we leave it.

If it were to be changed though, a percentage of one variable makes more sense to me. Also, the suggestion that Zytex made makes more sense for the name.

Rich

2010-12-30 10:50:34

randSpeed := (random(MouseSpeed) / 2.0 + MouseSpeed)
Is what's used to determine random MouseSpeed in MMouse, so
randSpeed := (random(KeySpeed) / 2.0 + KeySpeed)
would work fine? If that's the case, then the whole function would be:
var
OldLine, TheLine, TheName: string;
KeySpeed : Integer;

{ const clMessage, clChat, clTrade, clFriend
Description: Text colour constants. }
const
clMessage = clBlack;
clChat = clBlue;
clTrade = clPurple;
clFriend = 128;

//CODE CUT

{*******************************************************************************
procedure TypeSendEx(Text: string; PressEnter: Boolean);
By: SKy Scripter
Description: Sends human like text.
*******************************************************************************}
procedure TypeSendEx(Text: string; PressEnter: Boolean);
var
S: string;
I, L, randSpeed: Integer;
Shift: Boolean;
begin
if not InRange(KeySpeed, 20, 80) then
KeySpeed = 40;
randSpeed := (random(KeySpeed) / 2.0 + KeySpeed)
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(KeySpeed + Random(randSpeed));
while (Pos(Text[i], S) > 0) and (I <= Length(Text)) do
begin
TypeByte(GetKeyCode(Text[I]));
Wait(KeySpeed + Random(randSpeed));
Inc(I);
if (I > Length(Text)) then Break;
end;
end;
if (Shift) then
KeyUp(VK_SHIFT);
Wait(KeySpeed + Random(randSpeed));
if (I <= Length(Text)) then
begin
TypeByte(GetKeyCode(Text[I]));
Wait(KeySpeed + Random(randSpeed));
end;
end;
if (PressEnter) then
TypeByte(GetKeyCode(Chr(13)));
end;

Daniel

2010-12-31 03:25:11

From: Nava2
I think this should be done when we do the grand verhaul for personalization amongst the include. For now, we leave it.


Which will be when exactly? You've been saying the same thing for months and denying some changes to the include in favour of waiting for SRL5. Looking through the SRL5 repository, only minor update activity has occurred… Or unless you're purposely hiding it from us (which I don't see why)?

ZephyrsFury

2010-12-31 04:49:23

From: Daniel
Which will be when exactly? You've been saying the same thing for months and denying some changes to the include in favour of waiting for SRL5. Looking through the SRL5 repository, only minor update activity has occurred… Or unless you're purposely hiding it from us (which I don't see why)?


SRL 6 is the new overhaul now. SRL 5 is a clean up.

Rich

2010-12-31 09:50:16

When is SRL 6 expected then? Also, adding an extra option is hardly a bad thing, since it doesn't have to be used unless the scripter wants to use it.

i luffs yeww

2010-12-31 13:00:07

Afaik, SRL6 hasn't really been worked on yet.

Rich

2010-12-31 13:02:36

^ What about SRL 5?

i luffs yeww

2010-12-31 13:18:40

It's being developed more now than before, but I dunno about % completion or anything.

Nava2

2010-12-31 14:27:02

SRL 5 is almost ready for release.. Not sure if I'm supposed to say that, but just throwing it out there.

Frement

2010-12-31 14:28:00

From: Nava2
SRL 5 is almost ready for release.. Not sure if I'm supposed to say that, but just throwing it out there.


I think that has been said like month ago already.

Nava2

2010-12-31 16:44:30

From: Frement
I think that has been said like month ago already.


Nope.. not by me at least.

Daniel

2011-01-01 00:40:26

From: Nava2
SRL 5 is almost ready for release.. Not sure if I'm supposed to say that, but just throwing it out there.


Why's the development hidden then? The git repo for it hasn't been updated since 6 months ago…

Nava2

2011-01-01 01:16:33

From: Daniel
Why's the development hidden then? The git repo for it hasn't been updated since 6 months ago…


I'd love for that answer myself.

Rich

2011-06-23 12:36:58

Was going through the forums and noticed this. Thought I'd bump it since a final decision wasn't exactly reached.

Nava2

2011-06-23 13:35:19

Wish I had been right as well.. >.>

masterBB

2011-06-23 13:37:23

From: Nava2
Wish I had been right as well.. >.>


What happened to SRL 5/6 ?

Rich

2011-06-23 13:50:34

^That, and what is actually going to be the difference? Why not just update SRL as it needs to be updated, dd functions when they needs to be added, and remove functions when they become obsolete?