Jump to content
PuffOnThis

ReadString Procedure

Recommended Posts

I can't figure out how to get this ReadString procedure to work with newer versions of scar. D;

 

It works fine with Scar 3.13 (Outdated). Any help would be appreciated!

 

{READSTRING}
PROCEDURE ReadString(str: STRING);
VAR
i,StrLength :Integer;
Goer: Boolean;

BEGIN
i:=1
StrLength:=Length(Str)
Goer:=False
WHILE(i<StrLength+1)
DO BEGIN
IF(GetKeyCode(StrGet(Str,i))=191)
THEN BEGIN
KeyDown(16)
Goer:=True
i:=i+1
END;
KeyDown(GetKeyCode(StrGet(Str,i)))
WAIT(16);
KeyUp(GetKeyCode(StrGet(Str,i)))
WAIT(16);
KeyUp(GetKeyCode(StrGet(Str,i)))
WAIT(16);
i:=i+1
IF (Goer=True)
THEN BEGIN
KeyUp(16);
WAIT(400);
END;
END;
WAIT(400);
END;
{END OF READSTRING}

Link to comment
Share on other sites

Wow that was a fast reply! :) Well I have been working on a Script/Form for a while with scar 3.13. This procedure is suppose to read strings, so I can use my auto login procedure.

 

GetKeyCode was changed in newer versions to something else. I cannot figure this out, as I have looked everywhere!

 

Error- Unknown Identifier 'GetKeyCode'

Link to comment
Share on other sites

PuffOnThis unfortunately you are right.

Some of these things have been changed and the Manual is so incomplete it can be hard to find your way around.

 

I am sharing my Auto Login code with you that I use for Runescape, but it can be used absolutely anywhere.

I've used such names for Variables that you will be able to understand and I've included some comments to help you figure out what this code actually does, but it is really just like yours, only made to work with the latest version. I can answer any questions also.

 

procedure TypeThisIn(WhatToType : AnsiString);
var
StringLength : Integer;
CurrentPositionInString : Integer;
CharacterAtThisPosition : Char;
begin
 StringLength := Length(WhatToType); //This returns the amount of Characters that your String has
 for CurrentPositionInString := 1 to StringLength do //Standard For Loop, every time it repeats it Adds to CurrentPositionInString until it is the same as String Length
 begin
   CharacterAtThisPosition := StrGet(WhatToType, CurrentPositionInString); //Returns the Character from your String at this Position
   KeyDown(CharacterAtThisPosition); //Types it in
   Wait(Random(101) + 50);
   KeyUp(CharacterAtThisPosition); //Have to let go of the Key
   Wait(Random(101) + 50);
 end; //When the end of your String has been reached
 Wait(Random(251) + 250);
 VKeyDown(VK_RETURN); //Confirms by pressing Enter
 Wait(Random(101) + 50);
 VKeyUp(VK_RETURN); //Have to let go of the Key
end;

Edited by Creator
Link to comment
Share on other sites

I got it compiled fine, but it will not write my strings. =/ Is there not a simple replacement code for GetKeyCode?

It would make it so much easier. xD

 

The line below is the only code that I need to convert from 3.13>3.40

KeyDown(GetKeyCode(StrGet(Str,i)))

 

I'll try to mess around some more.

Edited by PuffOnThis
Link to comment
Share on other sites

Hello,

 

I can hardly believe that this doesn't function. Could you tell me what Game are you attempting to Bot?

Also, have you clicked anywhere where you can Type when running the program?

program TypeThisIn;
var
WhatToType : AnsiString;
StringLength : Integer;
CurrentPositionInString : Integer;
CharacterAtThisPosition : Char;
begin
 WhatToType := 'This should get Typed';
 StringLength := Length(WhatToType);
 for CurrentPositionInString := 1 to StringLength do
 begin
   CharacterAtThisPosition := StrGet(WhatToType, CurrentPositionInString);
   KeyDown(CharacterAtThisPosition);
   Wait(Random(101) + 50);
   KeyUp(CharacterAtThisPosition);
   Wait(Random(101) + 50);
 end;
 Wait(Random(251) + 250);
 VKeyDown(VK_RETURN);
 Wait(Random(101) + 50);
 VKeyUp(VK_RETURN);
end.

Before you run it, just click into the Debug Box at the bottom of SCAR and you should see it typed.

 

A good resource is found at this link, but I only found GetKeyCode in there and if it has been removed, there is not much you can do...

Link to comment
Share on other sites

The game I am trying this for is Endless Online. I have pretty much everything converted in my script from 3.13-3.40

 

I'm probably just doing something obvious wrong. Also, yes I know the text field is clicked, when it should be writing strings D;

 

The code you posted is not showing it typed in debug box also.

 

I have your procedure below.

procedure ReadString(WhatToType : AnsiString);
var
StringLength : Integer;
CurrentPositionInString : Integer;
CharacterAtThisPosition : Char;
begin
 StringLength := Length(WhatToType); //This returns the amount of Characters that your String has
 for CurrentPositionInString := 1 to StringLength do //Standard For Loop, every time it repeats it Adds to CurrentPositionInString until it is the same as String Length
 begin
   CharacterAtThisPosition := StrGet(WhatToType, CurrentPositionInString); //Returns the Character from your String at this Position
   KeyDown(CharacterAtThisPosition); //Types it in
   Wait(Random(101) + 50);
   KeyUp(CharacterAtThisPosition); //Have to let go of the Key
   Wait(Random(101) + 50);
 end; //When the end of your String has been reached
 Wait(Random(251) + 250);
 VKeyDown(VK_RETURN); //Confirms by pressing Enter
 Wait(Random(101) + 50);
 VKeyUp(VK_RETURN); //Have to let go of the Key
end;

 

I'm trying to call it in my auto relog procedure like below

IF FindColor(X,Y,7045797,414,344, 414,344)
THEN BEGIN
IF RelogClickSound = 1 THEN
PlaySound('C:\Program Files\WeedScriptSounds\RelogClick.wav');
WriteLn('[ENTERING USERNAME]')
WAIT(200);
ReadString(UserName);

Edited by PuffOnThis
Link to comment
Share on other sites

Well make sure that your UserName is in quotation marks. Other than that I can notice you're missing one set of Begin and End and one End, also your WriteLn should be Writeln and you're missing the semicolon after it. I'm not sure if these sytax differences between me and you actually make a difference but I'd write it as such.

if FindColor(X,Y,7045797,414,344, 414,344) then
begin
 if RelogClickSound = 1 then
 begin
   PlaySound('C:\Program Files\WeedScriptSounds\RelogClick.wav');
   Writeln('[ENTERING USERNAME]');
   Wait(200);
   ReadString('PuffOnThis');
 end;
end;

 

I've checked the Game out, its really cute and looks nice to play. I might try it out :o

Edited by Creator
Link to comment
Share on other sites

The semi colon is a legit mistake but did not effect my script at all.

Also, there was no END; because that was just a part of my relog procedure. It was the only part relevant to this. xD

 

 

The ReadString(UserName); is suppose to write my string located in my settings.ini. I do it like this example below.

 

 

VAR
UserName,Password,AltPath:String;

UserName:=ReadINI('WeedScript','User Name',AltPath);
ReadString(UserName);

 

I think you're thinking of doing it differently?

 

Edit- Didn't see your last sentence. xD People DDoS, and bot in this game alot. You can definitely check it out, but it's pretty much been a half dead game for years now. Also there are no admins around ever, and some annoying bugs, like character freezing in place every 5-10mins. I think that's caused from the owner screwing up his source. xD

Edited by PuffOnThis
Link to comment
Share on other sites

You are using it correctly, this should work.

 

The only reason why it wouldn't is if your Path would be wrong. Other than that is should operate without error.

Have you tried using Writeln to see what your INI search returns?

 

 

It is sad to see games die, but eventually all have to. I probably won't give it a look at. I'm surprised you're thinking of botting it at all.

I've looked at this .

Other than that I can tell you that I didn't work with Files at all and am perhaps the wrong address for your troubles...

Link to comment
Share on other sites

I definitely have the paths right, because everything in my script worked perfect in 3.13

Just to test, I tried WriteIn(UserName) and it did write in Debug Box. Something in your ReadString Procedure, will not work with this game I play I guess to type the text properly. :(

 

Yea this game honestly should have died a long time ago. This is the last game I'd tell others to start playing simply because of all the problems/ lack of players. The only reason I still play it at all, is because I have known good friends there for years now, and I find it fun to script, and make bots for it ect.

 

It's ok we couldn't get it to work, I really appreciate all your help though! I will get this fixed eventually. I am stubborn like that. = d I can't believe all this trouble because he removed one simple code! :(

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
  • Create New...