Results 1 to 3 of 3

Thread: Text.scar

  1. #1
    Join Date
    May 2008
    Location
    Canada
    Posts
    665
    Mentioned
    0 Post(s)
    Quoted
    7 Post(s)

    Default Text.scar

    Will Move Mouse randomly around an area until it detects a specific uptext
    Uses: Failsafe and when no other method work.

    SCAR Code:
    Function MouseAroundForUpTextEx(UpText:String;WaitMs,NumTrials,x1,y1,x2,y2:Integer):Boolean;
    var
      x,y,i:integer;
    begin
      repeat
        x := random(x2 - x1);
        y := random(y2 - y1);
        MMouse(x1,y1,x,y);
        wait(WaitMs+random(150));
        If(IsUpText(UpText))Then
        begin
          getmousepos(x, y);
          mouse(x, y, 0, 0, True);
          Result:= True;
          exit;
        end;
        wait(WaitMs+random(150));
        inc(i);
      until(i > NumTrials) xor (Result)
      if(i > NumTrials)then
        Result := False;
    end;


    SCAR Code:
    Function MouseAroundForUpText(UpText:String):Boolean;
    begin
      If(MouseAroundForUpTextEx(UpText,250,100,5,5,513,335))Then  // Covers RS Screen on min.
        Result := True;
    end;

  2. #2
    Join Date
    Feb 2009
    Location
    Hungary (GMT + 1)
    Posts
    1,774
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    SCAR Code:
    {*******************************************************************************
    function SpiralMouseMulti(var fx, fy: Integer; x1, y1, x2, y2: Integer; UpText: TStringArray; PpC, aInc: Integer): Boolean;
    By: Nava2
    Description: Spirals the mouse in a circle from the center of the defined box.
                 It will continue to spiral until it finds a spiral completely outside
                 the box, always skipping points outside.
                 Returns the occurance of the first occurance of UpText into fx, fy.
                 Takes multiple UpTexts as a TStringArray.
                 PpC: The number of pixels to increase per spiral.
                 aInc: The number of stops to make around each spiral.
                 Takes some testing to get the right combination of PpC and aInc.
    *******************************************************************************}


    {*******************************************************************************
    function SpiralMouse(var fx, fy: Integer; x1, y1, x2, y2: Integer; UpText: String; PpC, aInc: Integer): Boolean;
    By: Nava2
    Description: Spirals the mouse in a circle from the center of the defined box.
                 It will continue to spiral until it finds a spiral completely outside
                 the box, always skipping points outside.
                 Returns the occurance of the UpText into fx, fy.
                 PpC: The number of pixels to increase per spiral.
                 aInc: The number of stops to make around each spiral.
                 Takes some testing to get the right combination of PpC and aInc.
    *******************************************************************************}
    In mouse.scar.

    Addition to your functions:
    SCAR Code:
    function MouseAroundForUpTextEx(UpText:String; WaitMs, NumTrials, x1, y1, x2, y2: Integer): Boolean;
    var
      x, y, i: integer;

    begin
      Result := False;  //Although it's False at the beginning, it's a good programming habit to set it False by hand.
      repeat
        x := Random(x2 - x1);
        y := Random(y2 - y1);
        MMouse(x1, y1, x, y);
        Wait(WaitMs + Random(150));
        if (IsUpText(UpText)) then
        begin
          GetMousepos(x, y);
          Mouse(x, y, 0, 0, True);
          Result:= True;
          Exit;
        end;
        Wait(WaitMs + Random(150));
        Inc(i);
      until (i > NumTrials);
    end;
    You are exiting the function after you set the Result to True so it will never be True in the until line, also when you are out of the loop the Result will be False because it didn't find the UpText in time so no sense checking the same thing twice.

    SCAR Code:
    function MouseAroundForUpText(UpText: String): Boolean;
    begin
        Result := MouseAroundForUpTextEx(UpText, 250, 100, 5, 5, 513, 335);
    end;
    You can just do this.
    Last edited by Sabzi; 07-03-2010 at 10:41 AM.

  3. #3
    Join Date
    May 2008
    Location
    Canada
    Posts
    665
    Mentioned
    0 Post(s)
    Quoted
    7 Post(s)

    Default

    I missed Nava's function when going through srl ^^'. Thanks for the feedback + fix.

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
  •