Jump to content
MarkD

Make Scar find/read/save text

Recommended Posts

It has been a long time since I used Scar. Since I'm trying to build something that gathers information automatically, I thought maybe Scar could do it.

 

There are two boxes with coordinates to fill in, click a fixed location, click another fixed location and then it gets problematic. I need to find multiple locations with text in a given area, read them, sort them out and write the rest to a txt file. It all goes well, until the finding/reading part. The rest is no problem so far.

 

I know there are a few functions that should do the trick, but I'll write my own if I have to. The problem is, I'm used to C++ and haven't used Pascal based languages for a long time.

 

Does anyone have any suggestions about how to get this done?

I've heard about functions like GetTextAtEx, IsTextAtEx, IsTextInAreaEx, but the Scar-divi wiki can't find those functions.

 

SaveToFile() should save all variables to a file. I'm just hoping this will be a standard .txt file.

 

In C++, we got streams and getline to do the dirty work. How's that in Scar?

Link to comment
Share on other sites

It has been a long time since I used Scar. Since I'm trying to build something that gathers information automatically, I thought maybe Scar could do it.

 

There are two boxes with coordinates to fill in, click a fixed location, click another fixed location and then it gets problematic. I need to find multiple locations with text in a given area, read them, sort them out and write the rest to a txt file. It all goes well, until the finding/reading part. The rest is no problem so far.

 

I know there are a few functions that should do the trick, but I'll write my own if I have to. The problem is, I'm used to C++ and haven't used Pascal based languages for a long time.

 

Does anyone have any suggestions about how to get this done?

I've heard about functions like GetTextAtEx, IsTextAtEx, IsTextInAreaEx, but the Scar-divi wiki can't find those functions.

 

SaveToFile() should save all variables to a file. I'm just hoping this will be a standard .txt file.

 

In C++, we got streams and getline to do the dirty work. How's that in Scar?

 

Welcome back :P

 

Delphi, SCAR-Divi, Pascal Script, Pax compiler. They all use the same syntax sort of, but they have their differences. They all extremely relate to the Windows API, so you should always be able to find Win API functions. They support a lot of the stuff C++ has. Like TStreams, TOutPutStream, etc I don't know totally, because I haven't used them really. For GetLine, I'm assuming that pops up a text box to fill in? If so you can use a similar function in SCAR called ReadLn. SCAR is based off of Pax compiler, and some of the naming Freddy did for stuff differs from what it would be in Delphi/Free Pascal/ or whatever else.

 

The problem with what you want is...will the Text EVER overlap? If it does it might be impossible to read it. GetTextAt, and other legacy (haven't been updated in a while) functions, their documentation can be found in the old manual for SCAR located here. Just use CTRL+F and search for GetTextAt.

 

 

Yeah you could use SaveToFile. There is also other file functionality detailed here.

 

Note: SCAR Divi does not support multi-threading. But it does have TTimer, form components.

Link to comment
Share on other sites

I'll tell you a bit about getline. It doesn't really pop-up something, but since I'm writing console applications most of the time, that doesn't say much.

 

If we use the following:

	ifstream	input	("C:\\encinp.txt", ios::in);
string s;
	while ( input.good() )
	{
		getline (input,s);
		cout << s << endl;
	}

 

There is in incoming filestream from encinp.txt, with the name 'input'.

There also is a string (not a c_string).

 

What getline does, is reading the input till the '/n' sign (newline), and put it into the string we declared.

Cout is now able to print the string to screen.

 

So what getline does, is 'grabbing' text and pushing it into a string variable.

 

Now, I want to find if there is text. If there is, click it. There will be new text at a given place, which should be stored into a file. Best thing to do, I suppose, is to push them into strings and save those strings to a file. When the information is stored, click a given position and repeat this trick till there is no text left to click. I also need to think of something to make sure the same text doesn't get clicked twice, but that doesn't sound like much of a problem.

 

So, the pseudocode would look like something like this:

 

while(1){
LookforText();                        //search the screen for text, skipping excluded zones
ClickText();                           //click it
ReadTextFromGivenArea();       //read a given amount of lines on give coordinates, , will be a function like GetTextAtEx()
CheckText();                         //check whether the information is relevant, if not, skip towards ExcludeTextArea()
StoreText();                         //store the read data in strings
ExcludeTextArea();                //exclude the area from being clicked again
ClickCoordinates();                //click at a given point in screen
}

 

The text does and does not overlap. After ClickText, there will be a new screen in the left. It hovers over the other text, but makes what's under it visually disappear. Like throwing a blanket over it. It's still there, but you don't see it. Before that, there is no overlap.

 

function GetTextAtEx(x, y: Integer; Tolerance: Integer; Chars: Integer; CheckShadow, CheckOutline: Boolean; MinSpacing, MaxSpacing: Integer; TextColor: Integer; TextLength: Integer; Strict: Boolean; Range: TCharRange): string;

 

x,y would be the integers I get from the scan function.

Tolerance is irrelevant, since the text will be black.

Chars should be set by a function that reads what font it is, or manually by looking it up beforehand.

CheckShadow should be 0.

CheckOutline is probably irrelevant, or can I use this to any advantage?

Minspacing/Maxspacing will both be 0.

TextColor is black, so that's 0 on every colorchart.

TextLength will be about 15.

Strict should be 0 I guess.

Range will be tr_AllChars.

 

Is that how I should read it?

 

IsTextInAreaEx only says whether there is any text in the given area or not, not the coordinates at which the text is located. Is there any function for that as well, so those coordinates can be put into GetTextAtEx?

 

I'm not sure which is the better way to 'save' the strings. SavetoFile or WriteFileString. The latter one seems to be more like what I'm used to in C++.

 

It's not going to be finished in a few days, but it doesn't have to. I just thought it might be fun to try, see where it gets, hopefully get others enthousiastic for it as well :)

 

----

Q: Why this project?

A: It all started while I saw the game Ikariam, and remembered a tool we used to have (many years ago already) for Ogame called GalaxyTool. With the auto-click ability of Scar and reading the info from the screen, you could make something like that for almost any textbased RPG. Just put everything in a .txt, and read the .txt with a search engine (already built that almost a year ago in C++. Started as a telephone book, now it's a search engine for big files and even has encryption capabilities). Find everyone in a given guild/alliance, every village/planet of them or just lookup who has more/less points then you have. If I can get the datamining correct with Scar, the finding is ridiculously easy with C++. However, where games like Ogame have there information always stored at the same position on the screen, Ikariam has a random layout with their islands/villages. Makes it a lot more difficult and a lot more fun to build :)

Link to comment
Share on other sites

I'll tell you a bit about getline. It doesn't really pop-up something, but since I'm writing console applications most of the time, that doesn't say much.

 

If we use the following:

	ifstream	input	("C:\\encinp.txt", ios::in);
string s;
	while ( input.good() )
	{
		getline (input,s);
		cout << s << endl;
	}

 

There is in incoming filestream from encinp.txt, with the name 'input'.

There also is a string (not a c_string).

 

What getline does, is reading the input till the '/n' sign (newline), and put it into the string we declared.

Cout is now able to print the string to screen.

 

So what getline does, is 'grabbing' text and pushing it into a string variable.

 

Now, I want to find if there is text. If there is, click it. There will be new text at a given place, which should be stored into a file. Best thing to do, I suppose, is to push them into strings and save those strings to a file. When the information is stored, click a given position and repeat this trick till there is no text left to click. I also need to think of something to make sure the same text doesn't get clicked twice, but that doesn't sound like much of a problem.

 

So, the pseudocode would look like something like this:

 

while(1){
LookforText();                        //search the screen for text, skipping excluded zones
ClickText();                           //click it
ReadTextFromGivenArea();       //read a given amount of lines on give coordinates, , will be a function like GetTextAtEx()
CheckText();                         //check whether the information is relevant, if not, skip towards ExcludeTextArea()
StoreText();                         //store the read data in strings
ExcludeTextArea();                //exclude the area from being clicked again
ClickCoordinates();                //click at a given point in screen
}

 

The text does and does not overlap. After ClickText, there will be a new screen in the left. It hovers over the other text, but makes what's under it visually disappear. Like throwing a blanket over it. It's still there, but you don't see it. Before that, there is no overlap.

 

function GetTextAtEx(x, y: Integer; Tolerance: Integer; Chars: Integer; CheckShadow, CheckOutline: Boolean; MinSpacing, MaxSpacing: Integer; TextColor: Integer; TextLength: Integer; Strict: Boolean; Range: TCharRange): string;

 

x,y would be the integers I get from the scan function.

Tolerance is irrelevant, since the text will be black.

Chars should be set by a function that reads what font it is, or manually by looking it up beforehand.

CheckShadow should be 0.

CheckOutline is probably irrelevant, or can I use this to any advantage?

Minspacing/Maxspacing will both be 0.

TextColor is black, so that's 0 on every colorchart.

TextLength will be about 15.

Strict should be 0 I guess.

Range will be tr_AllChars.

 

Is that how I should read it?

 

IsTextInAreaEx only says whether there is any text in the given area or not, not the coordinates at which the text is located. Is there any function for that as well, so those coordinates can be put into GetTextAtEx?

 

I'm not sure which is the better way to 'save' the strings. SavetoFile or WriteFileString. The latter one seems to be more like what I'm used to in C++.

 

It's not going to be finished in a few days, but it doesn't have to. I just thought it might be fun to try, see where it gets, hopefully get others enthousiastic for it as well :)

 

----

Q: Why this project?

A: It all started while I saw the game Ikariam, and remembered a tool we used to have (many years ago already) for Ogame called GalaxyTool. With the auto-click ability of Scar and reading the info from the screen, you could make something like that for almost any textbased RPG. Just put everything in a .txt, and read the .txt with a search engine (already built that almost a year ago in C++. Started as a telephone book, now it's a search engine for big files and even has encryption capabilities). Find everyone in a given guild/alliance, every village/planet of them or just lookup who has more/less points then you have. If I can get the datamining correct with Scar, the finding is ridiculously easy with C++. However, where games like Ogame have there information always stored at the same position on the screen, Ikariam has a random layout with their islands/villages. Makes it a lot more difficult and a lot more fun to build :)

 

Lets just say your not the first one to come on here talking about text-based rpg's lols. One of many. Thank you for making me remember. Getline in C, or C++ with cout and cin. Those are all console based (DUH :D). You need to realize that Pascal syntax is about 5x easier then what your used to.

 

GetTextAt is a very powerful function. It drives the whole OCR functionality of SCAR.

 

Anyway, what you want to do isn't hard. You just need to get used to the syntax (maybe), and learn how all the functions work. Hit up the Tutorials & FAQ section here on the forums. There is a beginner tut's in there among other amusing things. Also Freddy, infamous creator of SCAR has videos in there of how to use it.

 

IsTextAt, and etc. Functions are useful because, you can do IsTextAt ( whereever) then try to use GetTextAt at the position it found the text.

 

If you need to make a font set - look here. But you can use SYSTEM fonts too. Like LoadSystemFont, and w/e functions.

 

 

 

Do not get frustrated with the OCR (On Screen Reading) functions. Just post your code on the forums if you need help, because they are sometimes hard to get working right. Consult the wiki's too.

Edited by LordJashin
Link to comment
Share on other sites

Either I'm not entirely used to the syntax, or I'm just trying to do something stupid.

At the moment I can't even get past selecting the islands, since my code seems to be skipping something.

 

What it should do, is insert the x and y coördinates in their correct boxes, hit Go, click on a given point (some icon will be exactly there), read all player data and return.

The reading part isn't written yet, but the rest should work. However, instead of selecting 16 islands, I only get 4. It seems like it's skipping x[1], x[3], y[1] and y[3].

 

program Sandbox;

var
 x,y : array [0..3] of string;
 xi,yi : integer;
 s : string;

begin
x[0] := '10';
x[1] := '11';
x[2] := '12';
x[3] := '13';
y[0] := '97';
y[1] := '98';
y[2] := '99';
y[3] := '100';
s := 'Done';

for xi := 0 to 3 do
begin

 for yi := 0 to 3 do
 begin
   MoveMouseSmooth(595, 920);
   HoldMouse(595,920,True);
   Wait(583);
   ReleaseMouse(620,920,True); //select what's in left box
   TypeKeys(x[xi]);             //give new coords for left box

   Wait(826);
   MoveMouseSmooth(660,920);
   HoldMouse(660,920,True);
   Wait(532);
   ReleaseMouse(680,920,True);
   TypeKeys(y[yi]);

   Wait(1218);
   MoveMouseSmooth(715,920);
   Wait(557);
   ClickMouse(715,920,True);   //click go
   Wait(767);
   MoveMouseSmooth(945,600);
   ClickMouse(945,600,True);   //click island

   //read something, do something with it, store it

   Wait(1184);
   MoveMouseSmooth(80,220);
   ClickMouse(80,220,True);     //return to world screen

   Wait(831);

   yi := yi + 1;  
 end;

 Wait(993);

 xi := xi +1;
end;

WriteLn(s);

end.

 

The amount of Wait statements is for two reasons. To give the server/browser time to update the data and to see what is happening.

Edited by MarkD
made it better readable
Link to comment
Share on other sites

Either I'm not entirely used to the syntax, or I'm just trying to do something stupid.

At the moment I can't even get past selecting the islands, since my code seems to be skipping something.

 

What it should do, is insert the x and y coördinates in their correct boxes, hit Go, click on a given point (some icon will be exactly there), read all player data and return.

The reading part isn't written yet, but the rest should work. However, instead of selecting 16 islands, I only get 4. It seems like it's skipping x[1], x[3], y[1] and y[3].

 

program Sandbox;

var
 x,y : array [0..3] of string;
 xi,yi : integer;
 s : string;

begin
x[0] := '10';
x[1] := '11';
x[2] := '12';
x[3] := '13';
y[0] := '97';
y[1] := '98';
y[2] := '99';
y[3] := '100';
s := 'Done';

for xi := 0 to 3 do
begin

 for yi := 0 to 3 do
 begin
   MoveMouseSmooth(595, 920);
   HoldMouse(595,920,True);
   Wait(583);
   ReleaseMouse(620,920,True); //select what's in left box
   TypeKeys(x[xi]);             //give new coords for left box

   Wait(826);
   MoveMouseSmooth(660,920);
   HoldMouse(660,920,True);
   Wait(532);
   ReleaseMouse(680,920,True);
   TypeKeys(y[yi]);

   Wait(1218);
   MoveMouseSmooth(715,920);
   Wait(557);
   ClickMouse(715,920,True);   //click go
   Wait(767);
   MoveMouseSmooth(945,600);
   ClickMouse(945,600,True);   //click island

   //read something, do something with it, store it

   Wait(1184);
   MoveMouseSmooth(80,220);
   ClickMouse(80,220,True);     //return to world screen

   Wait(831);

   yi := yi + 1;  
 end;

 Wait(993);

 xi := xi +1;
end;

WriteLn(s);

end.

 

The amount of Wait statements is for two reasons. To give the server/browser time to update the data and to see what is happening.

 

Have you ever used a development environment extensively? SCAR is a macro development environment, and has some of the same tools.

 

With SCAR Divi you have the ability to Pause the script, and step through it as it executes each line of code. So either using that or commenting out your own code, you can test if something works or not. SCAR 3.35 is new, but it should work good enough. But who knows maybe there's a bug in there with one of those functions?

http://forums.scar-divi.com/showthread.php?1088-Debugging - SCAR's stepping, and debugging system

 

http://forums.scar-divi.com/showthread.php?157-Break-Continue-Exit-keywords - Some SCAR keywords

http://forums.scar-divi.com/showthread.php?149-Methods-%28procedures-amp-functions%29 - Procedures and Functions in SCAR

http://forums.scar-divi.com/showthread.php?151-Loops-%28for-while-repeat-labels%29 - SCAR's looping methods

http://forums.scar-divi.com/showthread.php?148-Variables-amp-constants - SCAR's variables and constants

http://forums.scar-divi.com/showthread.php?19-Debugging-Common-Issues - DEBUGGING COMMON ISSUES - No video on that one

 

Also for the new SCAR Divi 3.35 - 3 videos in this thread, might learn something about the new stuff - http://forums.scar-divi.com/showthread.php?1603-SCAR-Divi-3-35-Preview-Tutorial

 

for loops in SCAR, usually you do not have to increment them urself. for i := 0 to 3, will go through the code once with 0, then again with 1 as i, then with 2 as i, etc. You do not need to increment i at all.

 

[sCAR]

program i;

 

var

i: Integer;

 

begin

for i := 0 to 3 do

WriteLn(i);

end.

[/sCAR]

 

This is probably why your y[yi] line skips a number.

Edited by LordJashin
Link to comment
Share on other sites

So, another difference between C++ and Pascal.

In C++, for loops are like this

for (int i = 0; i < 8; i++) {
}

 

It definitely is the cause for the problem I have, so that should be fixed easily.

 

I've used IDEs as Visual Studio and AVRStudio in the past, quite extensively as well.

I was already looking for something to keep track of my variables at each step in the progress, I guess a program like SCAR does have a tool like that somewhere.

 

I'll cut out the unnecesary increment, try to read some lines with OCR and keep this thread updated. So far, it's quite comprehensible. As long as you keep things logic, it doesn't matter in which language you've to write it.

Link to comment
Share on other sites

So, another difference between C++ and Pascal.

In C++, for loops are like this

for (int i = 0; i < 8; i++) {
}

 

It definitely is the cause for the problem I have, so that should be fixed easily.

 

I've used IDEs as Visual Studio and AVRStudio in the past, quite extensively as well.

I was already looking for something to keep track of my variables at each step in the progress, I guess a program like SCAR does have a tool like that somewhere.

 

I'll cut out the unnecesary increment, try to read some lines with OCR and keep this thread updated. So far, it's quite comprehensible. As long as you keep things logic, it doesn't matter in which language you've to write it.

 

Each language has its toll on its user. It doesn't matter what language its in, but it does to who ever wants to use it. IMO, pascal based languages are easier to understand, while providing most of what is needed. I think understanding a pascal based language fully would make it easier to learn C, C++, Windows API, etc. Because there is not a big learning curve really. There is no int main {}. No weird include headers like <windows.h>. And such weird hard to remember syntax. It makes computer programming harder when you dive straight into C, and C++ first or weird Windows API crap. And that slows down the learning IMO.

 

I actually learned C, and C++ and most of the general concepts good, but once I got to using it with Win API, I quit lol. Handling the messages, all the crap you had to put in there. It scared me. I think you have to do some of the memory handling too. I bet there's ways to make it easier but starting off it didn't look great. I like Delphi because it takes care of all that for you, same with Visual Basic. Never got past that point though.

 

When you hit the pause button on a script, the variables window shows up.

Edited by LordJashin
Link to comment
Share on other sites

First time I used SCAR, I only knew BASIC.

Now I've learned some extra languages, it definitely makes things more easy.

 

 

To prevent problems with the script in the future, I'll have to check if there is water instead of an island on the given coordinates.

 

i := 0;
i := GetColor(945,600);
WriteLn(i);
if i = blue then           //no, there shouldn't be text there, but I haven't found the color yet so it's pseudo
 Continue;

 

It doesn't really matter whether there is an island or not, the WriteLn() simply gives -1 at all times.

 

Another problem I've encountered is that I can't hit the pause key when the script is running. Ctrl + F4 just exits Firefox, script keeps running. Ctrl + F6 does nothing whatsoever.

 

@ Freddy, bedankt voor alle moeite die je in de video's gestoken hebt. Dat maakt het echt een stuk makkelijker om te leren!

Edited by MarkD
IntToStr wasn't really necessary in WriteLn, it prints integers just as good as strings :)
Link to comment
Share on other sites

First time I used SCAR, I only knew BASIC.

Now I've learned some extra languages, it definitely makes things more easy.

 

 

To prevent problems with the script in the future, I'll have to check if there is water instead of an island on the given coordinates.

 

i := 0;
i := GetColor(945,600);
WriteLn(i);
if i = blue then           //no, there shouldn't be text there, but I haven't found the color yet so it's pseudo
 Continue;

 

It doesn't really matter whether there is an island or not, the WriteLn() simply gives -1 at all times.

 

Another problem I've encountered is that I can't hit the pause key when the script is running. Ctrl + F4 just exits Firefox, script keeps running. Ctrl + F6 does nothing whatsoever.

 

@ Freddy, bedankt voor alle moeite die je in de video's gestoken hebt. Dat maakt het echt een stuk makkelijker om te leren!

 

In SCAR Divi, on the editor. CTRL+Space brings up the function list, from there you can see what GetColor returns, and basically the function prototypes. Except you won't see class anywhere (FREDDY) :P. Even though there is classes in SCAR.

 

As for your problem, it could be the the coords are off the client's dimensions or w/e. So it returns -1 because it cannot find a color beyond the scope of the client?

 

-1 in this case means not found!

Link to comment
Share on other sites

For file writing, there's a fairly extensive aPI with among other things [wiki=RewriteFile]RewriteFile[/wiki]. There are global hotkey bindings for some of the script controls with hotkeys differing from those used in SCAR internally. Check Tools=>Redefine Hotkeys

Link to comment
Share on other sites

Already thought that -1 meant some kind of error message, since there are absolutely no colorcharts that use a negative indication (not that I'm aware of anyway).

 

I haven't even selected a client, didn't need it for the mouse clicking part and the coords change when you select a client (other starting points etc).

So, you suggest I should select the client and try again?

 

Since I tried that, and on the given coordinates it returns 12876819. That's C47C13 in Hex and is nowhere near blue/black/whatever. That's some weird orange.

 

GetColor returns a Long Integer, but I haven't found out how to make those. I just put it in in integer, perhaps that is the problem? Old Manual said it returned an integer, but perhaps that changed.

 

EDIT: Cntrl + Alt + A is pause here. Never thought of the possibility to check my hotkeys :P Most IDE like programs don't even have a redefine or something like that.

Edited by MarkD
Link to comment
Share on other sites

Yea, I fixed the -1 problem. Seems like GetColor needs a set Client before it works.

For some reason, it gave a color I didn't ask for. I'll keep trying :)

 

Freddy, if a client isn't selected, then what is the client set as? I thought usually it was automatically set to the whole screen until you selected something?

 

If you are confused with the color system, try drawing the color on a bitmap, and then do DebugBitmap, but you have to put a wait after it. So do something like this:

 

[sCAR]

program New;

var

bmp: TSCARBitmap;

 

begin

bmp := TSCARBitmap.Create('');

bmp.Width := 50;

bmp.Height := 50;

FloodFill(bmp, 0, 0, GetColor(500, 500));

 

DebugBitmap(bmp);

 

Sleep(5000);

 

end.

 

[/sCAR]

Link to comment
Share on other sites

You can't not select a client, there's always one selected... But GetColor will return -1, in case the given coordinates are outside the maximum image area for the selected client.

 

Does SCAR not reset the client after it is closed? So it remembers the last client selected? Wouldn't it be better to have it reset every time?

Link to comment
Share on other sites

So, it could be reading colors from my desktop instead of from my Firefox.

I do have some orange'ish colors on my desktop, so that would explain a lot.

 

I'll do some rewriting, debug the thing and have it posted in the afternoon.

 

Now I stil haven't done any real OCR... But I better have a good base to start with before I insert any of that, saves a lot of trouble in the future.

Link to comment
Share on other sites

So, it could be reading colors from my desktop instead of from my Firefox.

I do have some orange'ish colors on my desktop, so that would explain a lot.

 

I'll do some rewriting, debug the thing and have it posted in the afternoon.

 

Now I stil haven't done any real OCR... But I better have a good base to start with before I insert any of that, saves a lot of trouble in the future.

 

You have to drag the crosshair over your browser first...

Link to comment
Share on other sites

I've dragged that crosshair to my browser about ten times to make sure it got it.

Can't really test it now, since I just updated to SCAR 3.35. Something about 'Control 'pnlSelectClient' has no parent window' the moment I drag the crosshair to the screen. Spammed someone's mailbox with the crash reports...

 

Just to make sure, the color it returns is given on the chart of the RGB standard?

It it's a different chart, it could still be blue instead of orange, or anything like that.

 

If I build in a SetClient thingy, would that make it failsafe?

Link to comment
Share on other sites

I've dragged that crosshair to my browser about ten times to make sure it got it.

Can't really test it now, since I just updated to SCAR 3.35. Something about 'Control 'pnlSelectClient' has no parent window' the moment I drag the crosshair to the screen. Spammed someone's mailbox with the crash reports...

 

Just to make sure, the color it returns is given on the chart of the RGB standard?

It it's a different chart, it could still be blue instead of orange, or anything like that.

 

If I build in a SetClient thingy, would that make it failsafe?

 

Sorry, missed this post.

 

The colors are RGB, yes.

R := Color and $FF;

G := (Color shr 8) and $FF;

B := (Color shr 16) and $FF;

 

What do you mean by failsafe though, for what?

Link to comment
Share on other sites

The debug shows me a very similiar color to what I expect, so it should be ok.

 

Current code:

program Sandbox;

var
 x,y : array [0..3] of string;
 xi,yi,water : integer;
 s : string;

begin
ClearDebug;
x[0] := '10';
x[1] := '11';
x[2] := '12';
x[3] := '13';
y[0] := '97';
y[1] := '98';
y[2] := '99';
y[3] := '100';
s := 'Done';
water := 11562771;

for xi := 0 to 3 do
begin
 Wait(993);

 for yi := 0 to 3 do
 begin
   Wait(931);
   MoveMouse(593,925);
   Wait(231);
   MouseBtnDown(593,925,False);
   Wait(583);
   MouseBtnUp(630,925,False); //select what's in left box
   TypeText(x[xi]);             //give new coords for left box

   Wait(826);
   MoveMouse(665,925);
   MouseBtnDown(665,925,False);
   Wait(532);
   MouseBtnUp(692,925,False); //select what's in right box
   TypeText(y[yi]);

   Wait(1218);
   MoveMouse(715,925);
   Wait(557);
   ClickMouse(715,925,False);   //click go
   Wait(767);
   MoveMouse(945,600);
   Wait(420);
   if (GetColor(945,600) = water) then   //if there is water instead of an island,
     Continue;                          //skip to next coordinate
   ClickMouse(945,600,False);   //click island
   WriteLn(xi);
   WriteLn(yi);

   //read something, do something with it, store it

   Wait(1184);
   MoveMouse(80,220);
   ClickMouse(80,225,False);     //return to world screen

 end;

end;

WriteLn(s);

end.

 

For some reason, the continue thingy does not what I expect it to do. As far as I know, it should skip the current For loop. However, I placed some writeln to check and all are executed, including the ones that should be skipped.

 

I'm trying to do some textreading now (GetTextAtEx), but the Chars part is giving trouble.

Chars specifies font number returned by LoadChars2 or LoadCharsFromFont2

LoadChars2 needs a font stored at my computer (probably unnecessary) and LoadCharsFromFont2 needs to know which font it is. How do I make sure which font it is? According to the source of the page, it's either Verdana, Arial, Helvetica or Sans-Serif. The only thing I know for sure is they're using charset utf-8.

Should I just try and find out? Or what's the 'correct' approach here?

 

There are also only 2 variables to give for the position. It doesn't read a box, it reads just one pixel. How the heck does that work? You can't put text in just one pixel :P

Well, you could zoom out of course, but that would be very small text. I haven't found a tutorial for it either and the search decided OCR is too short to search for. GetTextAtEx does give results, but none of them are any help.

 

EDIT: The moment I started this post, Freddy's wasn't written yet.

The failsafe is to make sure the correct client is set. So whatever the current client is, Firefox will be set as the new client.

Edited by MarkD
Link to comment
Share on other sites

I've dragged that crosshair to my browser about ten times to make sure it got it.

Can't really test it now, since I just updated to SCAR 3.35. Something about 'Control 'pnlSelectClient' has no parent window' the moment I drag the crosshair to the screen. Spammed someone's mailbox with the crash reports...

 

Just to make sure, the color it returns is given on the chart of the RGB standard?

It it's a different chart, it could still be blue instead of orange, or anything like that.

 

If I build in a SetClient thingy, would that make it failsafe?

 

Freddy, this is the exact error message I get on Windows XP too. It still works, but this error is annoying it pops up every time I select a client with the crosshairs.

omething about 'Control 'pnlSelectClient' has no parent window'

 

The debug shows me a very similiar color to what I expect, so it should be ok.

 

Current code:

program Sandbox;

var
 x,y : array [0..3] of string;
 xi,yi,water : integer;
 s : string;

begin
ClearDebug;
x[0] := '10';
x[1] := '11';
x[2] := '12';
x[3] := '13';
y[0] := '97';
y[1] := '98';
y[2] := '99';
y[3] := '100';
s := 'Done';
water := 11562771;

for xi := 0 to 3 do
begin
 Wait(993);

 for yi := 0 to 3 do
 begin
   Wait(931);
   MoveMouse(593,925);
   Wait(231);
   MouseBtnDown(593,925,False);
   Wait(583);
   MouseBtnUp(630,925,False); //select what's in left box
   TypeText(x[xi]);             //give new coords for left box

   Wait(826);
   MoveMouse(665,925);
   MouseBtnDown(665,925,False);
   Wait(532);
   MouseBtnUp(692,925,False); //select what's in right box
   TypeText(y[yi]);

   Wait(1218);
   MoveMouse(715,925);
   Wait(557);
   ClickMouse(715,925,False);   //click go
   Wait(767);
   MoveMouse(945,600);
   Wait(420);
   if (GetColor(945,600) = water) then   //if there is water instead of an island,
     Continue;                          //skip to next coordinate
   ClickMouse(945,600,False);   //click island
   WriteLn(xi);
   WriteLn(yi);

   //read something, do something with it, store it

   Wait(1184);
   MoveMouse(80,220);
   ClickMouse(80,225,False);     //return to world screen

 end;

end;

WriteLn(s);

end.

 

For some reason, the continue thingy does not what I expect it to do. As far as I know, it should skip the current For loop. However, I placed some writeln to check and all are executed, including the ones that should be skipped.

 

I'm trying to do some textreading now (GetTextAtEx), but the Chars part is giving trouble.

 

LoadChars2 needs a font stored at my computer (probably unnecessary) and LoadCharsFromFont2 needs to know which font it is. How do I make sure which font it is? According to the source of the page, it's either Verdana, Arial, Helvetica or Sans-Serif. The only thing I know for sure is they're using charset utf-8.

Should I just try and find out? Or what's the 'correct' approach here?

 

There are also only 2 variables to give for the position. It doesn't read a box, it reads just one pixel. How the heck does that work? You can't put text in just one pixel :P

Well, you could zoom out of course, but that would be very small text. I haven't found a tutorial for it either and the search decided OCR is too short to search for. GetTextAtEx does give results, but none of them are any help.

 

EDIT: The moment I started this post, Freddy's wasn't written yet.

The failsafe is to make sure the correct client is set. So whatever the current client is, Firefox will be set as the new client.

 

As I said before the OCR is tricky. You should be able to load whatever font you want but I'm not sure about this.

 

GetTextAtEx, you give it a point, and it will try to find each bitmap of the characters you're searching for to the right of the point. Min spacing, and max spacing is the amount of spacing between each character. I recommend setting them to none. Text color is self explanatory. Chars make it, tr_AllChars. That's what it says in the manual too. That basically means do you want to look for uppercase characters, lowercase, or all, etc. FONT SIZE matters here it is very important to this whole thing. If the font size changes all the time then it would be super hard to use this. When loading a system font make sure the size is the same as the one you are looking for.

 

GetTextAtEx, is very accurate, but extremely hard to use because everything has to be dead on. Tolerance is only for the colors.

Edited by LordJashin
Link to comment
Share on other sites

LordJashin, the problem with the crosshair is fixed. Also see this post.

 

If GetTextAtEx is so tricky, how do others solve the problem then? As I said, I've searched for clues and haven't found them. Hopefully will someone ever find this topic and get some answers from it ;-)

If I scroll out to maximum, I'll always have the same size font. However, it'll be barely readable. Zooming in is also a possibility, but then I can't fit everything on screen. Just 95% or so. Rolling my mousewheel 3 steps back from max zoom in would be the best way I guess. Since GetTextAtEx is so accurate, it would probably work. I just need to find a way to get to that position every time.

 

I also haven't found a solution for the problem with my continue statement.

if (GetColor(945,600) = water) then   //if there is water instead of an island,
     Continue;                          //skip to next coordinate

Why doesn't this skip the For loop it's currently in?

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...