Submenus and option buttons

Hi,

I am a newbie to the world of macros. I am trying to understand how it works.
So I have a process that requires to invoke a function in a program. On that window there are a number of options, first a drop down menu as well as various parameters that require to be checked or unchecked depending on how we want to process the data. I can call up the initial function through the open menu etc. but I am stuck from that point on.

Can it solely be done by recording mouse movement and location? I’ve tried it that way but I am not getting consistent results.

Checkboxes can generally be triggered with the Press Button action.

Popup menus are tricky to control. To select a popup menu, you need to simulate a click on the menu, and then use typeahead to select the desired item, ie actions:

Click on popup menu
Insert Text by Typing “Menu Name%Return%”

The tricky part is clicking on the menu. First, make sure you have paused long enough to allow the window to come to the front, and then you can need to click on the popup. You can click in one of these ways:

  • if the window has keyboard focus, then you can click relative to the window, and if the popup menu is in a fixed location, then that may be a reliable solution.
  • click relative to the found image. If the popup menu always defaults to the same thing, then you can use the popup menu as the image. Otherwise, you need to click relative to something nearby that is consistent (like some label text).

To click relative to an image, you use the Mouse Click action, configure it to be relative to a found image, and take a screenshot of the desired area of the screen using Command-Control-Shift-4, and paste it into the image well on the action. The image has to be unique (which includes not being visible in the action if the image is small enough not to be shrunk in the image well) otherwise Keyboard Maestro will not know where to click. The Display option in the action will allow you to see where Keyboard Maestro is matching.

Keep in mind with any click actions that you will generally need to ensure the screen is as you expect before the click action, so Pause actions may be needed, especially if any previous action has changed the window or caused some slow or animated behaviour to happen (eg opening a window or sheet).

Thanks for the quick reply. I don’t quite follow everything you say but will look up what you mention in documentation.

This function has several parameters that are used differently at times so the Press button action isn’t able to tell if an option is already checked right? Because simply clicking it will engage or disengage it but I need to be able to specify to have it on or off. Is there a way to do that?

If they are real checkboxes, and if the app is well behaved, then you can use the If Then Else action with the Button condition to determine if the checkbox is on or off.

Hey Marc,

There are things KM can do and things it can't. Many things in OSX do not have a public API and cannot be accessed directly by a macro utility. Some of those things can be worked-around by driving the user interface (UI), and some can't.

You haven't told us what program you're working with, so anything we say is generic information about how KM works and conjecture about your specific problem.

Give us enough information to really help you, and we might be able to get you over your disappointment. (No guarantees though.)

-Chris

Actually I deleted my previous post because after another 5 hours of experimentation I’ve done some major progress. I was able to accomplish most of the tasks I was hoping for, in combination with customizing and using my host app own short cuts and saving presets of more detailed functions. I’ve discovered for selecting from a drop down menus KM seems to work better with a keyboard selection once in the menu.

Now there is one last series of macros I’m struggling with that involves a drop down menu but keyboard selection is not possible in that menu and recording it with mouse and click doesn’t work.

FYI I am using it with Digital Performer a music making software

As I wrote above, for tricky popup menus, you need to click on them using the Found Image to ensure reliability (read my earlier reply on this).

If the click is not happening at all, likely that is caused by a timing issue - make sure the popup menu is there before you click.

After that, Insert Text by Typing and arrow keys should be helpful.

Thankfully I did not have to get into the Found Image as it sounds complicated and could not find any documentation on it. I was able to program the mouse movement and clicks by recording one step at a time and adding pauses after each movements. I also had to tweak the mouse position as well to make it work properly and consistently.

Thanks for your help

While recording, you can click the clock icon in the recording window to add a 1 second pause.