Enter Text Into Input Box in an Application

How to find an input box in an application window and enter some text? The use case is whenever an application starts (which I can trigger it by "This application" trigger), I want to the macro look for a specific input box, and enter some text if found that input box.

It's difficult to advise you without knowing more specifics, and it may depend on the app and the input field.

If you launch the app and the input box appears, can you type into it, or do you have to click on it first? Is it a standard macOS window, or something else?

If you were going to describe it to someone over the phone who needed the follow your instructions, what would describe to them?

Does the input box appear every time the app launches, or only some times?

The more specific you can be (screenshots may help, the name of the app may help, etc.) the more likely you will be too find someone who knows the answer.


Put KM into record mode, and then see what it does.
This can often be improved on, but it should get you going
Tip: Have another window open with a new doc in Textedit, then at various stages, type something in that window. These will act as "milestones"


Thanks for the response.

It is a login window for Cisco AnyConnect. See screenshot. It seems it appears in different position of the screen (which I can't find the pattern. What I want to do is that once this window appear, enter my Username in the first box and enter "PUSH" in the third box, then focus on the second box so I can type network password.

I tried the record mode, it seems it just records move and click using absolute position, however from what I observed, this window doesn't always at fixed position.

Often the TAB key can used be moved from one field to the next field (input box to input box) in a dialog such as you see. You can experiment to see it that is the case in this instance. Often Shift-TAB allows you to move back up a field.

So the KM script might be something like.

  1. Insert Text by Typing — Whatever your user name is

  2. Type a Keystroke — Tab -> jumps to the Network Password field

  3. Type a Keystroke — Tab -> jumps to the Verify Password field

  4. Insert Text by Typing — PUSH

  5. Type a Keystroke — Shift-Tab -> jumps back to to the Network Password field

It might work. As a general rule, if you can figure out how to do a task only using key strokes, then that is the better way to address the task with KM rather than having to specify mouse clicking.

One thing to note with mouse clicking, there is a way to specify as location relative to the upper left corner of the front-most window. It is one of the selectable options. Then if the dialog window that you describe is considered the frontmost window, you do not have to worry about where on the screen it is. You just specify clicking in a location so many pixels removed from the position of the upper corner of the window itself.

1 Like

This works perfectly, thank you!

1 Like

To use this method, is there any tool I can find the relative location (in pixels) from the upper corner of the window?

I don't think there is a direct way to get coordinates from the window corner, however you can use the "Mouse Display" to show the values of the mouse position.

Put your cursor at the top left of the window in question and make a note of the mouse position values. Then move to where you want Keyboard Maestro to click and calculate the difference from the values you noted and the current position. That will give you the values from the top left corner of the window for your macro.

Screen Shot 2020-11-03 at 8.59.33 PM

Have a look at this post TIP: How to Use the macOS ScreenShot Tool as a Screen Ruler which should help you out.

1 Like

The Click Mouse action can click relative to any corner of the front window or any corner of the main screen.

Alternatively, you can use the WINDOW or SCREEN functions to get the coordinates you desire and use arithmetic to adjust them, and click relative to the absolute position.

Keep in mind:

  • Offsets are always positive down and to the right, so from the top right corner, you may want a negative x offset.
  • Absolute coordinates are always from the top left corner of the main screen (the one with the menu bar on it in the System Preferences, Displays, Arrangement settings).
1 Like