Jump to content
Macro Express Forums

Waiting for Key Press - more choices


Recommended Posts

Hello. I want create a macro which is waiting not only for one keys rather two. If you chose A key goto "x". If i chose E key goto "y". Currently Macro Express don't support waiting for 'x' OR 'y' key. Can somebody help me with a workaround ?

Here is an example from my idea (careful it is not working !)

MessageBox: Info
Delay: 1 seconds
Wait for Key Press: A
OR
Wait for Key Press: E
// evaluation
Switch( %keystroke% )
Case: A
// do something useful
End Case
Case: E
// write some text
End Case
End Switch
-------------------------------------------------------------------------------------------------------------------
<MESSAGEBOX Caption="Info" Message="After clicking on OK the macro waiting for keypress 'A' or keypress 'E'" Icon="0"/>
<DELAY Flags="\x01" Time="1"/>
<WAIT FOR KEY PRESS Key="A" Indefinite="TRUE" Hours="0" Minutes="0" Seconds="0"/>
<OR/>
<WAIT FOR KEY PRESS Key="E" Indefinite="TRUE" Hours="0" Minutes="0" Seconds="0"/>
<COMMENT Value="evaluation"/>
<SWITCH Variable="%keystroke%"/>
<CASE Value="A"/>
<COMMENT Value="do something useful"/>
<END CASE/>
<CASE Value="E"/>
<COMMENT Value="write some text"/>
<END CASE/>
<END SWITCH/>

I appreciate every working idea

Link to comment
Share on other sites

Since you are using a message box, could you instead use the "Multiple Choice Menu" Dialog? 

I do have a possible solution for the situation you as presented it, but it is way more complicated -- have your primary macro start two other concurrent macros, one that waits for A and one that waits for E, and code a Repeat loop in the primary macro waiting for a signal from either one of the waiting macros. 

You can wait for "Any key" to be pressed.  It's too bad Macro Express doesn't insert the pressed key into a text variable -- then you could check whether it is A or E and re-issue the wait if not. 

Link to comment
Share on other sites

Here's an idea I wrote about several years ago which may, or may not, be helpful <g>! It's quite complex!

It is possible to write a total of 39 macros (one for each character and number, plus 3 control macros) which are fired according to which key has been pressed. Thus, pressing 3 intiates macro-3, pressing h initiates macro-h. It involves writing a total of 39 macros (most of which are almost identical)! See Detecting Keys pressed for details. But this works only in ME4.

Link to comment
Share on other sites

  • 4 weeks later...

Not much time to comment but waiting for for an unknown key is not something MEP does. Look in the forum and you will find dozens of times people have wanted this but it wasn't available. It's best to think of another way to do what you need. Paul has probably the most reasonable solution and to my way of thinking that's too complicated.

Link to comment
Share on other sites

You might consider making a feature request on their website.

I've been thinking of creating a generic .NET webform that a macro could define. Mainly people want to have multiple text fields. In my vision there my program would take text file as a command line parameter. Each line of the text file would create the form controls in a simplified way. EG text boxes, buttons, radio buttons, check boxes. Look in my posts for my offer. I could see creating a 'wait for key press' control. However no one seems interested in it so I can't justify spending the time to make what could be a very useful add-in. I would also like to make add-ins for RegEx, Web tasks and other functions MEP doesn't have. 

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