Jump to content
Macro Express Forums

Macro to select menu item


Recommended Posts

Most programs have menu items with no keyboard shortcuts.  I'd like to create a macro to select a menu item in a program, but I don't see any way of doing this.  I've looked and looked within the program and I've checked the user forums.  This seems like it should be pretty easy/simple, but it is definitely not obvious.  Can anyone provide any insight?  TIA.

Link to comment
Share on other sites

I first try to use the Windows Controls commands in MEP. This is by far the best way to interest with controls. However many newer UWP programs have different controls that are invisible to MEP. I typically start with the Get Control command. There's a control picker utility in there. If you hover the blue X over the control and it highlights it, then it will work. 

Next I will try hitting the Home (sometimes with Ctrl) button then tabbing though the controls counting. All windows programs should be able to tab to with the keyboard. 

As a last resort I will use the mouse. Mouse moves and clicks are problematic becasue the environment changes. Like a toolbar is enabled or a font size changes and then it fails and click in the wrong place . 

 

Aside: Windows controls commands are better for many other reasons. One big one is timing as there is a handy "Wait for control" command. 

 

Many people avoid Windows controls because it seems complicated and people get intimidated. They're not and should be one of the first things an MEP programmer learns as it will pay huge dividends into the future. If you don't know how, we can give you an edification. 

Link to comment
Share on other sites

The standard method to give keyboard input focus to the menu bar is to press either Alt or F10. If the menu bar (or ribbon) can be interacted with via keyboard, focus will jump there, and you will see it. Then menu items can be activated via arrow keys and/or "accelerator" keys.

 

For example, for the File menu, pressing Alt or F10 will change the appearance of File: the "F" will be highlighted, or underlined.

 

If this method works, a macro to navigate through menus can be simple. In pseudo code:

 

Type F10   // Activate the menubar

Type F      // Choose the _F_ile menu

Type A      // Choose Save _A_s

 

Sometimes you will need to insert a short delay between certain steps. 100 to 200 milliseconds is usually enough.

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