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.