Possible to prompt user to draw a box on the screen and store those coordinates for use in a macro?

Hello everyone!

As the title states, what I'm looking to do in KB Maestro is, upon triggering a macro, allow the user to use the mouse to click and drag a box (from top/left to bottom/right) around an area they choose on the screen. I need to store those box coordinates for use in other macros. Is this possible?

Thank you!!!

Do you need an actual box to be drawn? I would think that to be much more difficult than just recording the corners’ coordinates.

1 Like

The box does not need to be visible, if that's what you mean. Is it possible to prompt users to drag the coordinates and have them recorded if the user has no knowledge of Keyboard Maestro or how to use it beyond having it installed and launching my macro?

Keyboard Maestro does not really have anything to input a box, but it can record the screen coordinates. So you could do something like this:

  • Enable Macro "Capture Mouse"
  • Alert "Move the mouse to the start, press “x”, move the mouse to the end, press “x”, then press OK"
  • Disable Macro "Capture Mouse"
  • Use variables First Mouse and Second Mouse as the coordinates.

Macro "Capture Mouse", initially disabled.

  • Trigger on Hot Key “x”
  • Set variable "First Mouse" to text "%Variable%Second Mouse"
  • Set variable "Second Mouse" to text "%CurrentMouse%"
1 Like

Good idea! Thank you, I will report back.

I'm struggling to use the variables to define an area. For example:

OCR Area

I'm guessing it needs to be something like this?

Left: First Mouse.X
Down: Second Mouse.Y
Width: First Mouse.X to Second Mouse.X
Height: First Mouse.Y to Second Mouse.Y

But I don't know the proper syntax.

Thank you!!!


Nevermind, I figured it out.

Left: First Mouse.X
Down: Second Mouse.Y
Width: Second Mouse.X-First Mouse.X
Height: Second Mouse.Y-First Mouse.Y

Works great!

1 Like