Jump to content
Macro Express Forums

How to run a macro for a specific amount of time?


Recommended Posts

I know there MUST be an easy answer but for the life of me I don't see anything in any of the features. All I see are things like delay options but I don't want to delay (freeze) anything; just run the script for XX amount of minutes or an hour..

 

It's not clear to me what you want to do. Although your subject asks how to 'run a macro for a specific time', which is obviously trivially easy with a single delay command, you clearly want to do more than that. But what exactly? What does 'run the script' mean? What script?

 

I'm guessing that maybe you want to type or mouse-click continuously, or perhaps repeatedly at frequent intervals?

 

If so, here's a simple example:

 

// This will run for about 20 seconds. The 'script' will display the (approximate) number of seconds that have elapsed since the macro was started.

Repeat Until %N[1]% Equals "20"

Text Box Display: Counting seconds

Delay: 1 seconds

// This is where you would place the commands you want to run REPEATEDLY until the time limit is reached. Such as the Text Display command in this example.

Variable Modify Integer: %N[1]% = %N[1]% + 1

End Repeat

Macro Return

 

 

<COMMENT Value="This will run for about 20 seconds. The 'script' will display the (approximate) number of seconds that have elapsed since the macro was started."/>
<REPEAT UNTIL Variable="%N[1]%" Condition="\x00" Value="20"/>
<TEXT BOX DISPLAY Title="Counting seconds" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang2057{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs16 The macro has been running for approximately %N[1]% seconds\\f1 \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="FALSE" Keep_Focus="TRUE" Mode="\x02" Delay="1"/>
<DELAY Flags="\x01" Time="1"/>
<COMMENT Value="This is where you would place the commands you want to run REPEATEDLY until the time limit is reached. Such as the Text Display command in this example."/>
<VARIABLE MODIFY INTEGER Option="\x00" Destination="%N[1]%" Value1="%N[1]%" Value2="1"/>
<END REPEAT/>
<MACRO RETURN/>

 

 

--

Terry, East Grinstead, UK

Link to comment
Share on other sites

I know there MUST be an easy answer but for the life of me I don't see anything in any of the features. All I see are things like delay options but I don't want to delay (freeze) anything; just run the script for XX amount of minutes or an hour..

Like Terry I'm not 100% convinced I understand what you're trying to do, but I think I may be interpreting your needs differently than him.

 

Here is my suggestion:

Variable Set Integer %Minutes[1]%: Prompt
Variable Modify Integer: %Minutes[2]% = %Minutes[1]% * 60
Date/Time: Set %T[1]% to an adjusted date/time using "h:mm AMPM" as the format
Repeat Until %T[1]% Does not Equal "%T[1]%"
// Macro Code Goes Here: The following is only a sample, yours doesn't have to look like this.
 Get Pixel Color from Beneath the Mouse into %N[1]%
 Text Box Display: Color
 Delay: .5 seconds
 Text Box Close: Color
 Date/Time: Set %T[2]% to the current date/time using "h:mm AMPM" as the format
 If Variable %T[1]% Equals "%T[2]%"
Break
 End If
End Repeat

<VARIABLE SET INTEGER Option="\x01" Destination="%Minutes[1]%" Prompt="How long should this macro run? (In minutes)" Mask="FALSE" OnTop="FALSE" Left="Center" Top="Center" Monitor="0"/>
<VARIABLE MODIFY INTEGER Option="\x02" Destination="%Minutes[2]%" Value1="%Minutes[1]%" Value2="60"/>
<DATE/TIME Format="h:mm AMPM" Flags="\xB2" Date="1/19/2009 8:47:41 AM" Day_Offset="0" Month_Offset="0" Year_Offset="0" Hour_Offset="0" Minute_Offset="0" Second_Offset="%Minutes[2]%" Left="Center" Top="Center" Monitor="0" Variable="%T[1]%" IsDateVar="FALSE"/>
<REPEAT UNTIL Variable="%T[1]%" Condition="\x01" Value="%T[1]%"/>
<COMMENT Value="Macro Code Goes Here: The following is only a sample, yours doesn't have to look like this."/>
<GET PIXEL COLOR Option="\x00" Rel_To_Screen="TRUE" Destination="%N[1]%"/>
<TEXT BOX DISPLAY Title="Color" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs16 %N[1]%\\f1 \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="FALSE" Keep_Focus="TRUE" Mode="\x02" Delay="0"/>
<DELAY Flags="\x01" Time=".5"/>
<TEXT BOX CLOSE Header="Color"/>
<DATE/TIME Format="h:mm AMPM" Flags="\xB0" Date="1/19/2009 9:30:40 AM" Day_Offset="0" Month_Offset="0" Year_Offset="0" Hour_Offset="0" Minute_Offset="0" Second_Offset="0" Left="Center" Top="Center" Monitor="0" Variable="%T[2]%" IsDateVar="FALSE"/>
<IF VARIABLE Variable="%T[1]%" Condition="\x00" Value="%T[2]%" IgnoreCase="FALSE"/>
<BREAK/>
<END IF/>
<END REPEAT/>

 

Minutes[1] = the minutes you want the macro to run for

Minutes[2] = the number of seconds Minutes[1] is equal to

 

You could tweak the adjusted date/time however you see fit, I just went with what was simplest for me and my test macro.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...