Jump to content
Macro Express Forums

countdown display in a macro that already repeats


Recommended Posts

Ok, so what I am trying to do this time, is make a msg box that appears and shows a countdown timer from a variable. this macro already has a repeat function and the location I need this countdown to display in inside the repeat perimeters that is already there, for example.
 <VARIABLE SET INTEGER Option="\x05" Destination="%VarNum%" Minimum="12" Maximum="15"/>
<VARIABLE SET INTEGER Option="\x05" Destination="%LTimer%" Minimum="54987" Maximum="57143"/>
<DELAY Flags="\x02" Time="415"/>
<TEXT BOX DISPLAY Title="Pattern 1" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\qc\\b\\f0\\fs20 Mining Cycles Remaining\r\n\\par \\f1 %VarNum%\\b0\\fs16 \r\n\\par }\r\n" Left="613" Top="35" Width="197" Height="88" Monitor="0" OnTop="TRUE" Keep_Focus="FALSE" Mode="\x02" Delay="0"/>
<REPEAT UNTIL Variable="%VarNum%" Condition="\x02" Value="1"/>
<WINDOW ACTIVATE Title="cellinarac Atruin" Exact_Match="TRUE" Wildcards="FALSE" _IGNORE="0x0006"/>
<DELAY Flags="\x02" Time="645"/>
<MOUSE MOVE Option="\x01" X="994" Y="152" _PROMPT="0x000A"/>
<DELAY Flags="\x02" Time="348"/>
<MOUSE MOVE Option="\x01" X="995" Y="149" _PROMPT="0x000A"/>
<DELAY Flags="\x03" Time="500"/>
<MOUSE LEFT CLICK/>
<DELAY Flags="\x03" Time="327"/>
<TEXT TYPE Action="0" Text="<F1>"/>
<DELAY Flags="\x03" Time="500"/>
<TEXT TYPE Action="0" Text="<F2>"/>
<DELAY Flags="\x03" Time="%LTimer%"/>
THIS IS WHERE I WANT THE TIMER TO POP UP AND COUNTDOWN FROM THE %LTIMER% VARIABLE TO SHOW REMAINING TIME
<WINDOW ACTIVATE Title="cellinarac Atruin" Exact_Match="TRUE" Wildcards="FALSE" _IGNORE="0x0006"/>
<DELAY Flags="\x03" Time="500"/>
<TEXT TYPE Action="0" Text="<F1>"/>
<DELAY Flags="\x03" Time="500"/>
<TEXT TYPE Action="0" Text="<F2>"/>
<DELAY Flags="\x03" Time="500"/>
<VARIABLE MODIFY INTEGER Option="\x01" Destination="%VarNum%" Value1="%VarNum%" Value2="1"/>
<UPDATE TEXTBOX Header="Pattern 1" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\qc\\b\\f0\\fs20 Mining Cycles Remaining\r\n\\par \\f1 %VarNum%\\b0\\fs16 \r\n\\par }\r\n"/>
<END REPEAT/>
<TEXT BOX CLOSE Header="Pattern 1"/>
<MACRO RUN Use_ID="FALSE" Name="Pattern 2" ID="-1" Wait="TRUE"/>
<MACRO STOP/>

Link to comment
Share on other sites

If you want to visually see LTimer's value decrease, then I think you'll need a loop within a loop, where the inner loop shows your countdown once for ever time the outer loop loops.  

For example  if VarNum gets set to 14, then that LTimer will appear 14 times.  Each time it appears, it will count down from some value between approx. 54 and 57 seconds. 

Question: Do want LTimer to be reset with a different number 14 times?  Or do you want it to keep using the same start value for each of the 14 loops of VarNum?   

 

Edit:  Actually... I'm not positive if MacExpPro can even do a loop within a loop (sub-loop).  Experimenting now....

 

Yes you can.  It hurt my brain a little...  Notice in screenshot, that yellow highlight shows the outer loop.  Everything inside that loop is tabbed over to the right a few pixels.  Then blue highlight shows the inner loop.    At the bottom of the blue section is the inner "End Repeat" and at the bottom of the yellow is the outer "End Repeat".

 

se7N57j.png

 

<VARIABLE SET INTEGER Option="\x05" Destination="%VarNum%" Minimum="4" Maximum="12"/>
<TEXT BOX DISPLAY Title="Current Value" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil Tahoma;}{\\f1\\fnil\\fcharset0 Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs28 The variable, \"VarNum\" currently has the value %VarNum%.  \\f1 (BEFORE LOOP)\\f0\\fs16 \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="FALSE" Keep_Focus="TRUE" Mode="\x02" Delay="0"/>
<REPEAT UNTIL Variable="%VarNum%" Condition="\x02" Value="1"/>
<DELAY Flags="\x01" Time="1"/>
<TEXT BOX UPDATE Header="Current Value" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil Tahoma;}{\\f1\\fnil\\fcharset0 Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs28 The variable, \"VarNum\" currently has the value %VarNum%.  \\f1 (DURING LOOP)\\f0\\fs20 \r\n\\par }\r\n"/>
<VARIABLE MODIFY INTEGER Option="\x01" Destination="%VarNum%" Value1="%VarNum%" Value2="1"/>
<VARIABLE SET INTEGER Option="\x05" Destination="%VarSub%" Minimum="50" Maximum="100"/>
<TEXT BOX DISPLAY Title="Current Value Sub" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil Tahoma;}{\\f1\\fnil\\fcharset0 Tahoma;}}\r\n{\\colortbl ;\\red0\\green120\\blue215;}\r\n\\viewkind4\\uc1\\pard\\cf1\\f0\\fs28 The variable, \\f1 VarSub\\f0  currently has the value %Var\\f1 Sub\\f0 %.  \\f1 (BEFORE SUB LOOP)\\cf0\\f0\\fs16 \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="FALSE" Keep_Focus="TRUE" Mode="\x02" Delay="0"/>
<REPEAT UNTIL Variable="%VarSub%" Condition="\x02" Value="1"/>
<DELAY Flags="\x02" Time="10"/>
<TEXT BOX UPDATE Header="Current Value Sub" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil Tahoma;}{\\f1\\fnil\\fcharset0 Tahoma;}}\r\n{\\colortbl ;\\red0\\green120\\blue215;}\r\n\\viewkind4\\uc1\\pard\\cf1\\f0\\fs28 The variable, \"Var\\f1 Sub\\f0 \" currently has the value %Var\\f1 Sub\\f0 %.  \\f1 (DURING SUB LOOP)\\cf0\\f0\\fs20 \r\n\\par }\r\n"/>
<VARIABLE MODIFY INTEGER Option="\x01" Destination="%VarSub%" Value1="%VarSub%" Value2="1"/>
<END REPEAT/>
<TEXT BOX CLOSE Header="Current Value Sub"/>
<END REPEAT/>
<TEXT BOX CLOSE Header="Current Value"/>
<MESSAGEBOX Caption="Done" Message="Macro finished. " Icon="0"/>

 

This example is resetting VarSub (LTimer, for your purposes) each time the outer loop runs.  If you wanted it to use the same value each time, I suspect you'd need to "hand-off" the value to yet another variable.  Like

 

Set VarNum

Set LTimer

-Begin Outer Loop

-Set LTimerTemp (make it equal to LTimer)

-Begin Inner Loop, Loop while LTimerTemp < 1.

--blah blah

--Decrement LTimerTemp = LTimerTemp -1

-End Repeat

End Repeat

 

Note that I think it's best practice to use a single Variable Array, rather than a bunch of individual variables...  I'm not really sure how to do that though.   😕 

Link to comment
Share on other sites

33 minutes ago, kunkel321 said:

If you want to visually see LTimer's value decrease, then I think you'll need a loop within a loop, where the inner loop shows your countdown once for ever time the outer loop loops.  

For example  if VarNum gets set to 14, then that LTimer will appear 14 times.  Each time it appears, it will count down from some value between approx. 54 and 57 seconds. 

Question: Do want LTimer to be reset with a different number 14 times?  Or do you want it to keep using the same start value for each of the 14 loops of VarNum?   

 

Edit:  Actually... I'm not positive if MacExpPro can even do a loop within a loop (sub-loop).  Experimenting now....

what I am trying to get is a timer that displays the seconds left before moving on to the next part of the macro. in this case, the macro presses (F1) and (F2) then waits for a variable of 54 to 57 seconds before pressing those keys again, it repeats this process for 12 to 15 cycles and then moves on to the next steps in the macro. what I am trying to do, and "some what" got working, is to have a little timer box sitting in the corner that shows time left between the second set of key presses.  what I have so far works for the first cycle, but when it goes to the second cycle it starts the countdown at -1 instead of resetting to the variable of %LTimer%. this in turn removes the <DELAY Flags="\x03" Time="%LTimer%"/> because the displayed timer will replace the "delay". the first cycle works all the way down to "0" on the countdown display, then when the macro goes into it's second cycly of %VarNum% the box doesn't actually update or reset and starts off at -1 causing it to just rapidly press the keys. hopefully this all makes sense. here is what I have now.

 

<VARIABLE SET INTEGER Option="\x05" Destination="%VarNum%" Minimum="12" Maximum="15"/>
<VARIABLE SET INTEGER Option="\x05" Destination="%LTimer%" Minimum="54" Maximum="58"/>
<DELAY Flags="\x02" Time="415"/>
<TEXT BOX DISPLAY Title="Pattern 1" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\qc\\b\\f0\\fs20 Cycles Remaining\r\n\\par \\f1 %VarNum%\\b0\\fs16 \r\n\\par }\r\n" Left="613" Top="35" Width="197" Height="88" Monitor="0" OnTop="TRUE" Keep_Focus="FALSE" Mode="\x02" Delay="0"/>
<REPEAT UNTIL Variable="%VarNum%" Condition="\x02" Value="1"/>
<WINDOW ACTIVATE Title="cellinarac Atruin" Exact_Match="TRUE" Wildcards="FALSE" _IGNORE="0x0006"/>
<DELAY Flags="\x02" Time="645"/>
<MOUSE MOVE Option="\x01" X="994" Y="152" _PROMPT="0x000A"/>
<DELAY Flags="\x02" Time="348"/>
<MOUSE MOVE Option="\x01" X="995" Y="149" _PROMPT="0x000A"/>
<DELAY Flags="\x03" Time="500"/>
<MOUSE LEFT CLICK/>
<DELAY Flags="\x03" Time="327"/>
<TEXT TYPE Action="0" Text="<F1>"/>
<DELAY Flags="\x03" Time="500"/>
<TEXT TYPE Action="0" Text="<F2>"/>
<REPEAT UNTIL Variable="%LTimer%" Condition="\x02" Value="1"/>
<TEXT BOX DISPLAY Title="Timer" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\qc\\b\\f0\\fs20  Cycle Time Remaining\r\n\\par \\f1 %LTimer%\\f0  sec\\b0\\f1\\fs16 \r\n\\par }\r\n" Left="602" Top="107" Width="197" Height="88" Monitor="0" OnTop="TRUE" Keep_Focus="FALSE" Mode="\x02" Delay="0"/>
<DELAY Flags="\x03" Time="994"/>
<VARIABLE MODIFY INTEGER Option="\x01" Destination="%LTimer%" Value1="%LTimer%" Value2="1"/>
<UPDATE TEXTBOX Header="Timer" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\qc\\b\\f0\\fs20  Cycle Time Remaining\r\n\\par \\f1 %LTimer%\\f0  sec\\b0\\f1\\fs16 \r\n\\par }\r\n"/>
<TEXT BOX CLOSE Header="Timer"/>
<END REPEAT/>
<WINDOW ACTIVATE Title="cellinarac Atruin" Exact_Match="TRUE" Wildcards="FALSE" _IGNORE="0x0006"/>
<DELAY Flags="\x03" Time="500"/>
<TEXT TYPE Action="0" Text="<F1>"/>
<DELAY Flags="\x03" Time="500"/>
<TEXT TYPE Action="0" Text="<F2>"/>
<DELAY Flags="\x03" Time="500"/>
<VARIABLE MODIFY INTEGER Option="\x01" Destination="%VarNum%" Value1="%VarNum%" Value2="1"/>
<UPDATE TEXTBOX Header="Mining Pattern 1" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\qc\\b\\f0\\fs20 Cycles Remaining\r\n\\par \\f1 %VarNum%\\b0\\fs16 \r\n\\par }\r\n"/>
<END REPEAT/>
<TEXT BOX CLOSE Header="Pattern 1"/>
<DELAY Flags="\x03" Time="349"/>
<DELAY Flags="\x03" Time="367"/>
<MACRO RUN Use_ID="FALSE" Name="Pattern 2" ID="-1" Wait="TRUE"/>
<DELAY Flags="\x03" Time="362"/>
<MACRO STOP/>

Link to comment
Share on other sites

Here’s a method that could work:  
1)    In your primary macro, each time through the loop, write the value you want to display to an environment variable, or a text file, or a registry key, as you choose.  
2)    In your primary macro, start a secondary macro that runs concurrent with the primary.  
3)    The secondary macro will consist entirely of a Repeat loop with a one second delay inside the loop, or half-second, or multi-second, whatever makes you happy.  Each time through the loop, this secondary macro
    a.    retrieves the value stored by the primary,
    b.    displays the value in a text box,
    c.    waits for the delay time,
    d.    closes the text box, and
    e.    continues to repeat indefinitely.   
4)    As the secondary macro loops, there will be a very short time – almost imperceptible – that the text box is closed and therefore not visible.  Each redisplay of the text box will contain the value most recently stored by the primary macro.  
5)    When the primary macro wants the secondary (text box) macro to stop displaying, it can store a special value like 9999999.  When the secondary finds that special value, it can exit from the Repeat loop and do a Macro Return.  

 

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...
×
×
  • Create New...