Results 1 to 15 of 15

Thread: MouseEx

  1. #1
    Join Date
    Oct 2007
    Location
    #srl
    Posts
    6,102
    Mentioned
    39 Post(s)
    Quoted
    62 Post(s)

    Default MouseEx

    I had assumed it was posted before but when I looked I didn't see it anywhere soo...

    SCAR Code:
    {*******************************************************************************
    procedure MouseEx(mousex, mousey, ranx, rany: Integer; UpText: String; left: Boolean);
    By: Mutant Squirrle, hy71194, and NCDS
    Description: Moves mouse, Checks for UpText, Then Click's.
    *******************************************************************************}

    procedure MouseEx(mousex, mousey, ranx, rany: Integer; UpText: String; left: Boolean);
    var
      a, b, c: Integer;
    begin
      MMouse(mousex, mousey, ranx, rany);
      Wait(60 + Random(30));
      if Pos(UpText, RS_GetUpText) > 0 then
      begin
        GetMousePos(b, c);
        HoldMouse(b, c, left);
        repeat
          Wait(20 + Random(30));
          a := a + 1;
        until (a > 4);
        GetMousePos(b, c);
        ReleaseMouse(b, c, left);
        Wait(100 + Random(100));
      end;
    end;

    I just use it to eliminate the
    SCAR Code:
    MMouse();
    if IsUpText() then
    Mouse();
    that every script has.

    All I added is an extra parameter to check the uptext before clicking.

    Out of curiosity..do you find this useful?

  2. #2
    Join Date
    Jul 2007
    Location
    Right now? Chair.
    Posts
    8,488
    Mentioned
    3 Post(s)
    Quoted
    12 Post(s)

    Default

    meh might as well make it use WaitUpText then. I think it's just too much. you're just trying to skip a couple of lines without a real need or purpose except to skip them.

    sounds like RWait(500, 50) instead of wait(500+random(50)); i mean yeah, it makes it faster for you, but not more efficient nor better for srl nor anything very noticeable.

    ~RM

    I & I know Zion. It is in the spirit, body and mind of every one of us
    RMouse(obj: TMSIObject): boolean;

  3. #3
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    I like the idea, and I would certainly use it myself, but I do agree with RM, it's only skipping a couple lines for your own convenience.
    Last edited by Coh3n; 06-30-2009 at 12:14 AM.

  4. #4
    Join Date
    Oct 2007
    Location
    #srl
    Posts
    6,102
    Mentioned
    39 Post(s)
    Quoted
    62 Post(s)

    Default

    Quote Originally Posted by Rasta Magician View Post
    meh might as well make it use WaitUpText then. I think it's just too much. you're just trying to skip a couple of lines without a real need or purpose except to skip them.

    sounds like RWait(500, 50) instead of wait(500+random(50)); i mean yeah, it makes it faster for you, but not more efficient nor better for srl nor anything very noticeable.

    ~RM
    Out of curiosity..what is then the difference between FindTextTPA and FindTextTPAEx, or ChooseOptionEx and ChooseOption etc.

    It seems like there is an abundance of functions in SRL that do exactly what you say is not necessary to be done.

    I agree with what you said, but why, if that is the outlook we are supposed to have, do these other functions that are comparable in the same way, continue to exist in SRL?
    Last edited by NCDS; 06-30-2009 at 03:10 AM.

  5. #5
    Join Date
    Jul 2007
    Location
    Right now? Chair.
    Posts
    8,488
    Mentioned
    3 Post(s)
    Quoted
    12 Post(s)

    Default

    Quote Originally Posted by NCDS View Post
    Out of curiosity..what is then the difference between FindTextTPA and FindTextTPAEx, or ChooseOptionEx and ChooseOption etc.

    It seems like there is an abundance of functions in SRL that do exactly what you say is not necessary to be done.

    I agree with what you said, but why, if that is the outlook we are supposed to have, do these other functions that are comparable in the same way, continue to exist in SRL?
    Indeed, they are comparable. FindTextTPAEx requires you to have 2 vars which you would not need further on, while FindTextTPA declares those vars for you and frees them as soon as it is done instead of you having the vars throughout your whole procedure, increasing efficiency.

    And ChooseOptionEx and ChooseOption simplify things for you, and increases readability, and most new scripters would not grasp the concept of have a TStringArray with only one string, especially as arrays are more complicated than simple variables.

    Finally, Removing these said functions would break an awful lot of scripts and would make them backwards imcompatible, which is the same reason for which we have some routines with just one line, so we don't break scripts.

    Last but not least, this would not make your script anymore efficient, just a bit shorter, and maybe you weren't around before SRL 4, but i wouldn't like to go back to SRL 3.xx where we had OpenBank, OpenBank2, OpenBank3, OpenBankQuiet, OpenBankFast and OpenBankGlass, if you understand what i mean. Each of them having a slight difference between themselves.

    However, if another developer finds this to be a good addition they will add it, but i won't.

    ~RM

    I & I know Zion. It is in the spirit, body and mind of every one of us
    RMouse(obj: TMSIObject): boolean;

  6. #6
    Join Date
    Oct 2007
    Location
    #srl
    Posts
    6,102
    Mentioned
    39 Post(s)
    Quoted
    62 Post(s)

    Default

    Quote Originally Posted by Rasta Magician View Post
    Indeed, they are comparable. FindTextTPAEx requires you to have 2 vars which you would not need further on, while FindTextTPA declares those vars for you and frees them as soon as it is done instead of you having the vars throughout your whole procedure, increasing efficiency.

    And ChooseOptionEx and ChooseOption simplify things for you, and increases readability, and most new scripters would not grasp the concept of have a TStringArray with only one string, especially as arrays are more complicated than simple variables.

    Finally, Removing these said functions would break an awful lot of scripts and would make them backwards imcompatible, which is the same reason for which we have some routines with just one line, so we don't break scripts.

    Last but not least, this would not make your script anymore efficient, just a bit shorter, and maybe you weren't around before SRL 4, but i wouldn't like to go back to SRL 3.xx where we had OpenBank, OpenBank2, OpenBank3, OpenBankQuiet, OpenBankFast and OpenBankGlass, if you understand what i mean. Each of them having a slight difference between themselves.

    However, if another developer finds this to be a good addition they will add it, but i won't.

    ~RM
    No, I agree with you. Everything you said make's sense and is backed up by a valid point.

    I just enjoy these little "Q and A" discussions to make sure I am on the same page as everyone else.

    tbh I didn't post this with the intention of it being added to SRL, more so to just share ideas with people

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

    Default

    honestly, i would use it if it was added :P any thing to shorten up a script by just a few lines, and save a little bit of time is well worth it right?
    <TViYH> i had a dream about you again awkwardsaw
    Malachi 2:3

  8. #8
    Join Date
    Oct 2007
    Location
    #srl
    Posts
    6,102
    Mentioned
    39 Post(s)
    Quoted
    62 Post(s)

    Default

    Quote Originally Posted by akwardsaw View Post
    honestly, i would use it if it was added :P any thing to shorten up a script by just a few lines, and save a little bit of time is well worth it right?
    My thought's as well, but RM does have a good point.

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

    Default

    Quote Originally Posted by NCDS View Post
    My thought's as well, but RM does have a good point.
    yes, he does :P i just like being lazy when i just want to finish a script(bad habbit i know)
    <TViYH> i had a dream about you again awkwardsaw
    Malachi 2:3

  10. #10
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Rasta Magician View Post
    Indeed, they are comparable. FindTextTPAEx requires you to have 2 vars which you would not need further on, while FindTextTPA declares those vars for you and frees them as soon as it is done instead of you having the vars throughout your whole procedure, increasing efficiency.

    And ChooseOptionEx and ChooseOption simplify things for you, and increases readability, and most new scripters would not grasp the concept of have a TStringArray with only one string, especially as arrays are more complicated than simple variables.

    Finally, Removing these said functions would break an awful lot of scripts and would make them backwards imcompatible, which is the same reason for which we have some routines with just one line, so we don't break scripts.

    Last but not least, this would not make your script anymore efficient, just a bit shorter, and maybe you weren't around before SRL 4, but i wouldn't like to go back to SRL 3.xx where we had OpenBank, OpenBank2, OpenBank3, OpenBankQuiet, OpenBankFast and OpenBankGlass, if you understand what i mean. Each of them having a slight difference between themselves.

    However, if another developer finds this to be a good addition they will add it, but i won't.

    ~RM
    I was also told by somebody that ChooseOptionEx was faster.

  11. #11
    Join Date
    Dec 2007
    Location
    192.168.1.73
    Posts
    2,439
    Mentioned
    6 Post(s)
    Quoted
    119 Post(s)

    Default

    Quote Originally Posted by Da 0wner View Post
    I was also told by somebody that ChooseOptionEx was faster.
    Well, look at it this way, when you use ChooseOption, it has to access ChooseOptionEx, like this:

    Function called --> ChooseOption --> ChooseOptionEx

    But when you use ChooseOptionEx, its gets rid of the ChooseOption:

    Function called --> ChooseOptionEx

    And if you really wanted efficiency, then you could have your own function of which the colours and everything were set to your liking, saving accessing the include.

  12. #12
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    ChooseOption wasn't just ChooseOptionEx last time I saw it. They modified it.

    ChooseOption was a whole different procedure.

  13. #13
    Join Date
    Dec 2007
    Location
    192.168.1.73
    Posts
    2,439
    Mentioned
    6 Post(s)
    Quoted
    119 Post(s)

    Default

    SCAR Code:
    {*******************************************************************************
    function ChooseOptionMultiEx(Texts: TStringArray; TextType: String; Action: fnct_ActionOptions): Boolean;
    By: Wizzup?, Nava2, and modified by N1ke!
    Description: Finds Popup menu, then clicks on it.
                 Will look for the first string first and so on.
                 It will search for the Text Type you input valid arguments are
                 'action', 'player': The white text
                 'npc': The yellow text
                 'object': The cyan text
                 'all': Searches for all colors of text.
                 Will default to 'all'.
    *******************************************************************************}

    function ChooseOptionMultiEx(Texts: TStringArray; TextType: String; Action: fnct_ActionOptions): Boolean;
    var
       B, T: TBox;
       TPA, TextTPA: TPointArray;
       aTPA: T2DPointArray;
       I, C, H, HH, ii, L: Integer;
       P: TPoint;
       Occurances: array [0..4] of TPointArray;
       Colors: TIntegerArray;
    begin
      Result := False;
      GetClientDimensions(B.X2, B.Y2);
      B.X1 := 0;
      B.Y1 := 0;
      FindColorsTolerance(TPA, 4674653, B.X1, B.Y1, B.X2, B.Y2, 0);
      If Length(TPA) < 10 Then
        Exit;
      B.X2 := 0;
      B.Y2 := 0;

      P := TPA[0];
      H := High(TPA);
      Dec(H);
      For I := 0 To H Do
        If TPA[i].X = TPA[I+1].X - 1 Then
        Begin
          If C > 5 Then
          Begin
            B.X1 := P.X;
            B.Y1 := P.Y;
            Break;
          End Else
            C := C + 1;
        End
        Else
        Begin
          P := TPA[I + 1];
          C := 0;
        End;
      If I = Length(TPA) Then
      Begin
        WriteLn('Choose Option Menu Getting Failed');
        Exit;
      End;
      InvertTPA(TPA);
      C := 0;
      P := TPA[0];
      H := High(TPA);
      Dec(H);
      For I := 0 To H Do
        If TPA[i].X = TPA[I+1].X + 1 Then
        Begin
          If C > 5 Then
          Begin
            B.X2 := P.X;
            B.Y2 := P.Y;
            Break;
          End Else
            C := C + 1;
        End Else
        Begin
          P := TPA[I + 1];
          C := 0;
        End;
      If I = Length(TPA) Then
      Begin
        WriteLn('Choose Option Menu Getting Failed');
        Exit;
      End;

      TPA := [];
      Colors := [16777215, 4231423, 2070783, 65535, 16776960];
      case LowerCase(TextType) of
        'action', 'player': FindColorsTolerance(Occurances[0], Colors[0], B.x1, B.y1, B.x2, B.y2, 3);
        'item'  : begin
                    FindColorsTolerance(Occurances[1], Colors[1], B.x1, B.y1, B.x2, B.y2, 3);
                    FindColorsTolerance(Occurances[2], Colors[2], B.x1, B.y1, B.x2, B.y2, 3);
                  end;
        'npc'   : FindColorsTolerance(Occurances[3], Colors[3], B.x1, B.y1, B.x2, B.y2, 3);
        'object': FindColorsTolerance(Occurances[4], Colors[4], B.x1, B.y1, B.x2, B.y2, 3);
        else
        begin
          FindColorsTolerance(Occurances[0], 4674653, B.X1, B.Y1, B.X2, B.Y2, 0);
          FindColorsTolerance(Occurances[1], clBlack, B.X1, B.Y1, B.X2, B.Y2, 0);
          TPA := MergeATPA(Occurances);

          ClearDoubleTPA(TPA);
          TPA := ReturnPointsNotInTPA(TPA, B);
        end;
      end;
      if High(TPA) < 1 then TPA := MergeATPA(Occurances);
      aTPA := SplitTPAEx(TPA, 7, 1);
      SortATPAFromFirstPoint(aTPA, Point(B.x1, B.y1));

      H := High(Texts);
      L := High(aTPA);

      For I :=0 To H do
      begin
        TextTPA := LoadTextTPA(Texts[I], UpChars, HH);
        for ii := 0 to L do
          If FindTextTPAInTPA(HH, TextTPA, aTPA[ii], TPA) Then
          Begin
            T := GetTPABounds(TPA);
            Result := True;
            Case Action of
              ClickLeft: MouseBox(B.x1 + 5, T.y1 + 2, B.x2 - 5, T.y2 - 2, 1);
              Move:      MouseBox(B.x1 + 5, T.y1 + 2, B.x2 - 5, T.y2 - 2, 3);
              Nothing:   begin end;
              else
                srl_warn('ChooseOptionMultiEx', 'ClickRight not a valid click for RS menus!', warn_AllVersions);
            end;
            Exit;
          End;
      end;

      MMouse(B.X1 - 50, B.Y1 - 50, 40, B.Y2 - B.Y1);
      Wait(200 + Random(100));
    end;

    {*******************************************************************************
    function ChooseOptionMulti(Text: TStringArray): Boolean;
    By: Wizzup? modified by N1ke!
    Description: Finds Popup menu, then clicks on it.
    Will look for the first string first and so on.
    *******************************************************************************}

    function ChooseOptionMulti(Txt: TStringArray): Boolean;
    begin
      Result := ChooseOptionMultiEx(Txt, 'All', ClickLeft);
    end;

    {*******************************************************************************
    function ChooseOptionEx(Txt, TextType: string): Boolean;
    By: Wizzup?
    Description: Finds an option in a popup menu, then clicks on it. Searches for
                 TextType. See ChooseOptionMultiEx for valid options.
                 Default is 'all'.
    *******************************************************************************}

    function ChooseOptionEx(Txt, TextType: string): Boolean;
    begin
      Result := ChooseOptionMultiEx([Txt], TextType, ClickLeft);
    end;

    {*******************************************************************************
    function ChooseOption(txt: String): Boolean;
    By: Wizzup?
    Description: Finds an option in a popup menu, then clicks on it.
    *******************************************************************************}

    function ChooseOption(Txt: String): Boolean;
    begin
      Result := ChooseOptionMultiEx([Txt], 'All', ClickLeft);
    end;

    Its all based around ChooseOptionMultiEx

  14. #14
    Join Date
    Mar 2008
    Location
    In a cave
    Posts
    345
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Well, ChooseOption uses 'all' as TextType where instead you could speed things up by using ChooseOptionEx with a specific TextType

    For example I use in my Fally smelter ChooseOptionMultiEx with 'action' to withdraw ores from bank. It's almost a second faster for me...

    EDIT: [OnTopic] I like the idea, but I don't think it's really something that's really needed...[/OnTopic]
    Last edited by bugger0001; 07-10-2009 at 04:35 AM. Reason: Typo
    A Chinese wiseman once said: "Shu ciu!", it was considered very smart, but now people know it means: "Something stinks here!"
    FalBuggySmelter v.1.31
    [Updated on the 1st of March 2010]
    RimmBugger BETA V1.8

  15. #15
    Join Date
    Jun 2009
    Location
    The Netherlands
    Posts
    79
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    We're getting a little of topic XD?

    Anyway, I think its a great function, yes it is just skipping a couple of lines, but how many times do you use that in a script? Well I do quite a lot...

    Current Project:

    ChompieChopper - Early stages.

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
  •