View Full Version : waiting stuff...
so basically, i have a procedure and i want it to do something like
procedure aasdfdfszc;
begin
mouse(x,y);
end;
i want to add a failsafe. this failsafe will give the procedure 4 seconds to finish it, otherwise it cancel it and carry on to the next procedure. how can i do this?
YoHoJo
05-02-2012, 05:52 AM
Using MarkTime and TimeFromMark.
Usally used in/before a loop like
MarkTime(MyTimer)
Repeat
Stuffs
If TimeFromMark(MyTimer) > 4000 Then Break
Until False
'MyTimer' would need to be defined as an integer. You also would need to include SRL since MarkTime/TimeFromMark are SRL functions.
procedure Waiting;
begin
MarkTime(MyTimer)
Repeat
asdfasdf; //the procedure that i want to immediately stop after 4000ms
If TimeFromMark(MyTimer) > 4000 Then Break
Until(False);
end;
so is this right?
YoHoJo
05-02-2012, 06:04 AM
That will keep doing asdfasdf over and over for 4 seconds.
so what do you recommend?, change until(false)?
YoHoJo
05-02-2012, 06:16 AM
It would help to know exactly what the entire procured you are using/want to stop is.
So you want it to stop after 4 seconds even if each line in the procedure hasn't completed?
Procedure LoadingPleaseWait;
begin
Loading := BitmapFromString(20, 9, 'meJxjYCAZ/P//n3RN5OuFa8FkYLI' +
'hAKshmLL4DcTFQCZxGU6kXkrsJVIvrmDB42a4LACY1Zho');
repeat
wait(1);
until (FindBitmapToleranceIn(Loading, x, y, ScreenX1, ScreenY1, ScreenX2, ScreenY2, 0)); //loading screen detected
writeln('loading screen detected.');
begin
repeat
wait(1);
until not (FindBitmapToleranceIn(Loading, x, y, ScreenX1, ScreenY1, ScreenX2, ScreenY2, 0)); //loaded
KeyUp(38);
wait(50 + random(50));
end;
FreeBitmap(Loading);
end; here is the procedure, it is for a rsps btw hence the loading bitmaps and stuff. and yes i want it to stop after 4 seconds even if it hasnt completed all the lines
YoHoJo
05-02-2012, 06:18 AM
I guess just at beginning MarkTime.
Then after each line in the procedure put
If TimeFromMark(MyTimer) > 4000 Then Exit
the main problem is here,
repeat
wait(1);
until (FindBitmapToleranceIn(Loading, x, y, ScreenX1, ScreenY1, ScreenX2, ScreenY2, 0)); //loading screen detected, its for a rsps.
where it may not always detect the loading screen, so would this be changed to
repeat
wait(1);
If TimeFromMark(MyTimer) > 4000 Then Exit
until (FindBitmapToleranceIn(Loading, x, y, ScreenX1, ScreenY1, ScreenX2, ScreenY2, 0)); //loading screen detected
YoHoJo
05-02-2012, 06:29 AM
Change Exit to Break, and I think that will do what you want it do to.
Maybe add some tolerance to the bitmap?
Also try checking for a pixel that is always the same color, either on the screen before the loading screen, or the loading screen itself.
Then search that one pixel for the color (or lack of the color) to see if you are in/out of the loading screen, get it :/?
Powered by vBulletin® Version 4.2.1 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.