Jump to content
Macro Express Forums

Waiting for More Than One Event


Recommended Posts

This is related to a post in ME3 forum related to waiting for more than one event. I did not see much point in point in posting in that forum. Here's a crude method of having alternative "Wait For" states. I've used two key presses as it's easier to demonstrate. Because the time resolution is at least 1 sec per item, it's not very responsive. Keypresses work best by tapping the key. I'm not sure if anything like this has been posted - if it has here's a reminder. The ding is just to give an indication it's looping (change to your choice).

 

The macro loops ignoring errors and skipping the GoTo commands. When a key is pressed the macro jumps out of the loop to do the desired actions.

 

:start
Sound File: DING.WAV
Wait for Key Press: A
On Error
 Catch Error: The condition was not met within the specified amount of time
Goto:SKIP KEYPRESS A
 End Catch Error
End Error
Goto:WHATEVER YOU NEED TO DO 1
:SKIP KEYPRESS A
Wait for Key Press: B
On Error
 Catch Error: The condition was not met within the specified amount of time
Goto:SKIP KEYPRESS B
 End Catch Error
End Error
Goto:WHATEVER YOU NEED TO DO 2
:SKIP KEYPRESS B
Goto:start
:WHATEVER YOU NEED TO DO 1
Text Box Display: Key Press A
Macro Stop
:WHATEVER YOU NEED TO DO 2
Text Box Display: Key Press B
Macro Stop

 

 

<LABEL Name="start"/>
<SOUND FILE File="C:\\Program Files\\Macro Express Aux\\DING.WAV" Wait="FALSE" _PROMPT="0x0007"/>
<WAIT FOR KEY PRESS Key="A" Indefinite="FALSE" Hours="0" Minutes="0" Seconds="1" _HANDLE="0x0014"/>
<ON ERROR/>
<CATCH ERROR Code="20"/>
<GOTO Name="SKIP KEYPRESS A"/>
<END CATCH ERROR/>
<END ERROR/>
<GOTO Name="WHATEVER YOU NEED TO DO 1"/>
<LABEL Name="SKIP KEYPRESS A"/>
<WAIT FOR KEY PRESS Key="B" Indefinite="FALSE" Hours="0" Minutes="0" Seconds="2" _HANDLE="0x0014"/>
<ON ERROR/>
<CATCH ERROR Code="20"/>
<GOTO Name="SKIP KEYPRESS B"/>
<END CATCH ERROR/>
<END ERROR/>
<GOTO Name="WHATEVER YOU NEED TO DO 2"/>
<LABEL Name="SKIP KEYPRESS B"/>
<GOTO Name="start"/>
<LABEL Name="WHATEVER YOU NEED TO DO 1"/>
<TEXT BOX DISPLAY Title="Key Press A" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs16 \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="FALSE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/>
<MACRO STOP/>
<LABEL Name="WHATEVER YOU NEED TO DO 2"/>
<TEXT BOX DISPLAY Title="Key Press B" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs16 \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="FALSE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/>
<MACRO STOP/>

Link to comment
Share on other sites

This is related to a post in ME3 forum related to waiting for more than one event. I did not see much point in point in posting in that forum. Here's a crude method of having alternative "Wait For" states. I've used two key presses as it's easier to demonstrate. Because the time resolution is at least 1 sec per item, it's not very responsive. Keypresses work best by tapping the key. I'm not sure if anything like this has been posted - if it has here's a reminder. The ding is just to give an indication it's looping (change to your choice).

 

The macro loops ignoring errors and skipping the GoTo commands. When a key is pressed the macro jumps out of the loop to do the desired actions.

See KeyPress macros for a similar technique, except that the desired key presses

are waited for all at the same time, instead of serially as in the example above.

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...