Results 1 to 8 of 8

Thread: Two questions. SendKeys and Filtering TPA

  1. #1
    Join Date
    Jun 2007
    Posts
    532
    Mentioned
    1 Post(s)
    Quoted
    68 Post(s)

    Default Two questions. SendKeys and Filtering TPA

    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.


    Simba Code:
    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!!

    Simba Code:
    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.

    Simba Code:
    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.

    Debug1.pngDebug1.png

    How do I ignore the other points?
    Finished B.S. Program in Radiology!!

    Projects: A big one! Total secret! hehe

  2. #2
    Join Date
    May 2007
    Location
    knoxville
    Posts
    2,873
    Mentioned
    7 Post(s)
    Quoted
    70 Post(s)

    Default

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

    And for your tpas, you can add something like
    Simba Code:
    if length(atpa[i]) < mintpalength then continue;
    in your for ATPA do loop. Or even then, you could just pick a different color
    <TViYH> i had a dream about you again awkwardsaw
    Malachi 2:3

  3. #3
    Join Date
    Jun 2007
    Posts
    532
    Mentioned
    1 Post(s)
    Quoted
    68 Post(s)

    Default

    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"
    Finished B.S. Program in Radiology!!

    Projects: A big one! Total secret! hehe

  4. #4
    Join Date
    May 2007
    Location
    knoxville
    Posts
    2,873
    Mentioned
    7 Post(s)
    Quoted
    70 Post(s)

    Default

    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
    <TViYH> i had a dream about you again awkwardsaw
    Malachi 2:3

  5. #5
    Join Date
    Apr 2013
    Posts
    395
    Mentioned
    1 Post(s)
    Quoted
    177 Post(s)

    Default

    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.

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

  6. #6
    Join Date
    Jun 2007
    Posts
    532
    Mentioned
    1 Post(s)
    Quoted
    68 Post(s)

    Default

    Quote Originally Posted by Haxz View Post
    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.

    Simba Code:
    Function AmountScreen: Boolean;
    begin
      ColorToleranceSpeed(1);
      Result := CountColorTolerance(0, 9, 347, 95, 468, 10) < 10;
    end;
    You are miss understanding me.

    option.png

    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.
    Finished B.S. Program in Radiology!!

    Projects: A big one! Total secret! hehe

  7. #7
    Join Date
    Apr 2013
    Posts
    395
    Mentioned
    1 Post(s)
    Quoted
    177 Post(s)

    Default

    Quote Originally Posted by Element17 View Post
    You are miss understanding me.

    option.png

    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.
    Simba Code:
    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.

  8. #8
    Join Date
    Jun 2007
    Posts
    532
    Mentioned
    1 Post(s)
    Quoted
    68 Post(s)

    Default

    Quote Originally Posted by Haxz View Post
    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.
    Simba Code:
    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.
    Finished B.S. Program in Radiology!!

    Projects: A big one! Total secret! hehe

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •