Jump to content
Macro Express Forums

If next pressed is " enter "


slacker

Recommended Posts

I need some help writing a macro in ME ver 3.7 where I don't want to take my hands off the keyboard (to use a mouse), and I don't want to press 2 keys. 

 

The macro "abc" is triggered by a hotkey, say f11, and does this:

 

(run next 3 commands then)

if the next key pressed is "enter"

run macro "xyz"

else if f11 key is pressed again it restart macro "abc"

 

I have searched all over and cannot find a way to do this. I even tried using VBA code in msword forums but I don't have the know-how to write that code. 

 

Any suggestions to get me started are appreciated. Slacker 

Link to comment
Share on other sites

2 hours ago, slacker said:

(run next 3 commands then)

if the next key pressed is "enter"

run macro "xyz"

else if f11 key is pressed again it restart macro "abc"

 

Macro "abc" can do whatever, then run macro "def" (without waiting for "def" to finish), and "abc" ends.  In other words, the "IF" logic in your example will NOT exist in macro "abc". 

 

Macro "def" issues command "Wait for Key Press", waiting for the Enter key.  When Enter is pressed, "def" runs "xyz" (again, without waiting for "xyz" to finish), and "def" ends. 

 

So if the user presses Enter, "xyz" will be run by "def".  If the user presses f11, "abc" will run because f11 is the hotkey for "abc". 

 

Your problem, if the user presses f11, is that macro "def" is still running, waiting for the user to (potentially) press Enter.  The easiest way out of this might be to set a short time limit on "Wait for Key Press" and end "def" without running "xyz" if Enter does not happen.  Whether a short timer will work depends on the nature of the application you are working with.  Otherwise you have to set up some kind of feedback among the macros so that "def" can be ended without running "xyz". 

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