Posts: 1
Threads: 1
Joined: Oct 2011
can i use my clock on my pc to end my macro? hope i say that correctly. i am having issues with understanding how to let my macro and or function run with a timer. for some reason its over my head. if i can do this action, should i have a separate macro or function to run this? i 'd wish to run it for example 6 hours then stop. i can manually start it again when needed thru my toolbar. i am not a macro genius as you may guessed so i probably need it explained in layman terms. thank you
Posts: 11,922
Threads: 138
Joined: Dec 2002
Create function that ends the macro.
Use tim to run the function after 6 hours.
Function
start_my_macro
mac "my_macro" ;;run macro "my_macro"
tim 6*60*60 end_my_macro ;;after 6 hours run function "end_my_macro"
Function
end_my_macro
tim ;;stop this timer
shutdown -6 0 "my_macro" ;;end macro "my_macro"
---------
Or let the macro end itself after 6 hours. Probably the macro does something repeatedly. Then it can use GetTickCount to see how long it is running.
Macro
Macro1582
;add this at the beginning of the macro
int t1=GetTickCount
int t2=6000*60*60 ;;6 hours
rep
,;add this at the beginning of the loop
,if(GetTickCount-t1>=t2) ret ;;end this macro if 6 hours passed
,;then your code
,1