These two functions involve finding the little "loading - please wait." screen that pops up in the corner when you load a new area. My connection isn't the best and my VM starts to lag a noticeable amount when I have 3+ clients open, so I made these to add to my scripts to help ignore the varying lag I have.
Hope someone else finds it useful as well.
Simba Code:
(*
findLoading()
by: HKbotz
Waits to find the small loading screen in the corner when entering new
areas. Returns true if it finds the loading screen, otherwise returns false.
-waitTime: time(in ms) to wait to find loading screen
-tol: the tolerance to use when searching for loading screen bitmap
usage:
findLoading(5000);
if (findLoading(5000, 15)) then
writeLn('Found the loading screen in corner.');
*)
function findLoading(waitTime: integer; tol: integer = 10): boolean;
var
loadingBMP: integer;
p: TPoint;
timer: TTimeMarker;
begin
result := false;
loadingBMP := BitmapFromString(29, 10, 'meJyTFROSpQ1ia7sgqWlEFaOA5g' +
'BNg7BZ+u9T0VigaXiMFfQrZJr5nmHRfyAJZCPrAgoCEV/iBLhiIBs' +
'iCHQqHmNFrQPhfoGEElAEbjKEAbROWl4J4gCu4g0QQSADj7EctQfg' +
'5kBsgWsEGgKUhbgNogtZMZCBx1igIcKuiXAukA0xlj+8EcgQN3JEj' +
'mjijUWWhSiAaASaALEOqB7uWlyBALQX4ikIQosyIIK7HOhOiAhQL1' +
'AW7higaRBxoL3IkUJ1BAAtAqT9');
timer.start();
repeat
if (findBitmapToleranceIn(loadingBMP, p.x, p.y, mainscreen.getBounds(), tol)) then
begin
print('Found loading screen.');
freeBitmap(loadingBMP);
exit(true);
end;
until (timer.getTime() >= waitTime);
print('Couldn''t find loading screen.');
freeBitmap(loadingBMP);
end;
(*
waitForLoading()
by: HKbotz
Finds loading screen, then waits for it to disappear. Returns true if it
was able to find the loading screen and wait for it to disappear again,
otherwise returns false.
-findWait: time(in ms) to wait to find loading screen
-waitTime: time(in ms) to wait for loading screen to go away
-tol: the tolerance to use when searching for loading screen bitmap
usage:
waitForLoading(5000, 5000);
if (waitForLoading(5000, 5000)) then
writeLn('Loaded new aread.');
*)
function waitForLoading(findWait, waitTime: integer; tol: integer = 10): boolean;
var
timer: TTimeMarker;
begin
result := false;
if (findLoading(findWait, tol)) then
begin
timer.start();
repeat
print('Waiting for loading screen to go away...');
if (not findLoading(0, tol)) then
begin
print('Can''t find load screen anymore, must have loaded.');
print('Time it took: ' + intToStr(timer.getTime()));
exit(true);
end;
until (timer.getTime() >= waitTime);
end;
print('Never found loading screen.');
end;