SRL Archive - OSR Help

Two questions. SendKeys and Filtering TPA


Element17

2013-06-09 18:56:18

This has been fixed, or at least found a way around it! See further on down.

I have this and it works up until the sendkeys part. I've tested sendkeys outside of the function and it works for what I am trying to do. Whenever I have it in the function is just clicks continue once then sits there when it should be selecting an option. I've also tried MMouse (and HumanMMOuse) doesn't work inside the function either.


function ChatBox: Boolean;
begin
while (areTalking()) do
clickContinue(true, true); //
sendkeys('2', 250, 250);
clickContinue(true, true);
clickContinue(true, true);
sendkeys('80', 100, 100);
TypeByte(VK_ENTER);
if (FindBlackChatMessage('You''ll need to unlock your money pouch to afford that much seaweed.')) then
begin
writeln('Need to enter pin at bank.');
Result := False;
Exit;
end else begin
clickContinue(true, true);
end;
end;

FIXED!!


function Arhein_ChatBox: Boolean;
begin
while (areTalking()) do
TypeByte(VK_SPACE);
findNPCChatText('2', ClickLeft);
The problem seems to be with clickContinue(true, true);, not sure why.



Second question is about TPA filtering.


Function Find_Arhein: Boolean;
var
CTS: Integer;
Black_TPA, White_TPA, Player_TPA: TPointArray;
ATPA: array of TPointArray;
Black_Box: TBox;
begin
if (not (LoggedIn)) then
Exit;
Player_TPA := TPAFromBox(IntToBox(245, 130, 285, 195));
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.46, 6.88);

if FindColorsSpiralTolerance(MSCX, MSCY, Black_TPA, 1316130, MSX1, MSY1, MSX2, MSY2, 5) then // black
begin
Black_TPA := ClearTPAFromTPA(Black_TPA, Player_TPA);
RAaSTPA(Black_TPA, 5);
ATPA := SplitTPAEx(Black_TPA, 20, 20);
SortATPAFromFirstPoint(ATPA, Point(MSCX,MSCY));
DeBugATPABounds(ATPA);
for i := 0 to High(ATPA) do
begin
Black_Box := GetTPABounds(ATPA[i]);
SetColorSpeed2Modifiers(2.58, 3.42); //change for white
if FindColorsSpiralTolerance(MSCX, MSCY, White_TPA, 14805433, MSX1, MSY1, MSX2, MSY2, 15) then //white
White_TPA := ClearTPAFromTPA(White_TPA, Player_TPA);
break;
if i = high(ATPA) then
begin
writeln('Check all the TPA''s, did not find black and white');
LogOut;
TerminateScript;
end;
end;
SetColorToleranceSpeed(1);
SetColorSpeed2Modifiers(0.2, 0.2);
MarkTime(t);
while (not IsUpTextMultiCustom(['Talk', 'Arhein'])) do
begin
MiddleTPAEx(ATPA[i], x, y);
HumanMMouse(x, y, 5, 5);
Writeln(GetUpText);
if WaitUpTextMulti(['Talk', 'Arhein'], 400) then
Writeln('UpText match');
if TimeFromMark(t) > 5000 then
begin
writeln('Took to long to find uptext');
Logout;
TerminateScript;
end;
end;
ClickMouse2(True);
Result := True;
Exit;
end;
end;

I have this and it find Arhein almost every single time. The only problem is there are 'Men' and sometimes other players around who match and it picks up on them a little and sometimes clicks on them.

[ATTACH=CONFIG]21616[/ATTACH][ATTACH=CONFIG]21616[/ATTACH]

How do I ignore the other points?

Awkwardsaw

2013-06-09 20:30:13

so, you're saying that sendkeys() just doesn't type anything?

And for your tpas, you can add something like
if length(atpa[i]) < mintpalength then continue;
in your for ATPA do loop. Or even then, you could just pick a different color

Element17

2013-06-09 20:55:28

Thanks for the TPA help.

As for the sendkeys I am trying to use it to select an option in the NPC chat. It had worked outside the function when I just used it alone it would select the option. Once inside the function it doesn't choose anything. I wonder if it has something to do with While "aretalking"

Awkwardsaw

2013-06-09 21:04:33

perhaps it's typing '2' before it actually needs to be typed? I didn't even know you can type something for NPC chat, so I can't really help with that

Haxz

2013-06-09 21:13:10

There's some wait time right after you clicked to continue, and during that time script already did the sendtype function. Make yourself a function that can detect the chatbox where you can type in amount, so you can repeat wait until it finds the type in amount chatbox. I did this in my flax spinner script.


Function AmountScreen: Boolean;
begin
ColorToleranceSpeed(1);
Result := CountColorTolerance(0, 9, 347, 95, 468, 10) < 10;
end;

Element17

2013-06-11 01:25:59

From: Haxz
There's some wait time right after you clicked to continue, and during that time script already did the sendtype function. Make yourself a function that can detect the chatbox where you can type in amount, so you can repeat wait until it finds the type in amount chatbox. I did this in my flax spinner script.


Function AmountScreen: Boolean;
begin
ColorToleranceSpeed(1);
Result := CountColorTolerance(0, 9, 347, 95, 468, 10) < 10;
end;


You are miss understanding me.

[ATTACH=CONFIG]21652[/ATTACH]

This menu or anyone like it if you press 2 on the keyboard it will select that option. When I use said above in my script outside of the function it works, but inside the function it just sits there.

Haxz

2013-06-11 09:02:46

From: Element17
You are miss understanding me.

[ATTACH=CONFIG]21652[/ATTACH]

This menu or anyone like it if you press 2 on the keyboard it will select that option. When I use said above in my script outside of the function it works, but inside the function it just sits there.


I see, I thought you wanted to type in the amount since after sendkey of number 2, you have a 80.

Maybe you can try this.

repeat
ClickContinue(true, true);
until FindNPCChatText('2', ClickLeft);

As for the TPA. Maybe you can try to sort the TPA by size. So it will find the TPA with highest count first. I assume you're finding the NPC by the color of the pants. From the picture, it seems like the black color on NPC pants will have the highest length in points compare to the others in a 20x20 square.

Element17

2013-06-11 12:14:11

From: Haxz
I see, I thought you wanted to type in the amount since after sendkey of number 2, you have a 80.

Maybe you can try this.

repeat
ClickContinue(true, true);
until FindNPCChatText('2', ClickLeft);

As for the TPA. Maybe you can try to sort the TPA by size. So it will find the TPA with highest count first. I assume you're finding the NPC by the color of the pants. From the picture, it seems like the black color on NPC pants will have the highest length in points compare to the others in a 20x20 square.


I will try that for the NPC chat.

As for the TPA I think I may already be sorting it by size, but it doesn't seem to taking into account the second TPA, white, that I have put in also. I will mess around with it some more and see what I can come up with. If I get the NPC chat working I will update OP and put my fix in. Thanks for your help.