Move or Click Mouse


I want to make a shortcut to open the KM Preferences window / Variables pane.
Usually on widows with multiple tabs the standard mac shortcut is Command +1, Command +2 …etc. To switch tabs.
This doesn’t seem to be the case in the Prefs window, as those keys are use for opening KM windows.
I figure I use Move or Click Mouse.
Set it to click the Variables tab. But the click point that is set isn’t related to the Window.

Long story short, I solved this by using AppleScript System Events.
click button Variables of toolbar 1 of Preferences:General

But since I’m coming over from QKeys I wanted to see how it would be done with standard KM.
QKeys could set mouse clicks relative to specific windows.

I built just such a macro late last year, but just now posted.
Please let us know if this meets your needs.

It remaps the macOS standard key for app preferences, ,, to open KM Preferences to the Variables pane, and then selects the Variable Search box. Of course you can change the trigger to be whatever you like.

###MACRO: @KM Search KM Variables in Preferences

Thx I checked out your macro.
I already programmed the macro using Apple Script.
What I was after, and I guess you just verified it by doing it the the same way.
Basically KM doesn’t know how to remember points relative to a specific window.
Those chores are done via Apple Script, correct?

I’m not sure I understand your question.
But KM can do a mouse click relative to the screen, a window, or the current mouse location. See Move or Click Mouse action (KM Wiki).

Is that what you meant?

I must be doing something wrong .
When I set a point relative to a window, like a prefs window. Then if that window is in a different location the next time it opens, and I use the macro. The mouse click is at the point where it was programmed not at the new location.

Have you tried something like this:

I set up the Move/Click the same as yours.
Use the get button to grab a location on a window.
After it gets the point it reads Move/Click at (265, 41) from the top left corner of the…
How are you getting the Relative to Window to happen?

EDIT: 2017-06-03 3:49 PM CT

That provides you with the absolute screen position.
I was wrong about that statement.

To get the relative position, you have two choices:

  1. First set the “relative to” option as you like, for example: ““relative to front window’s top left corner””
  • Now click on the “Get” button
  • A countdown will start.
  • Position your mouse at the point in the Window where you want.
  • Wait for the “pop” sound indicating the position has been set.
  • see Determine Location of Area to Search for Found Image. The approach used there applies to your use case.

Ok got it.
I guess I’m a little puzzled, coming over from Quickeys, which hasn’t beed updated in forever.
It can do window relative clicks so easily.
Anywa,y thanks for your time answering my questions.

I'm not sure I understand your comment.
It is also very easy to do in KM. Just takes one action.

Actually, I misspoke earlier. AFTER you set the "relative to front window's top left corner", then clicking on the Get button will return/set the relative position. I just tried and confirmed it.

Hmmm I just now got it to work as expected.
It must have been a front window thing??
Anyway I’m very glad to see that. I have so many shortcuts that I’m moving over that depend on that
Thx for hanging with me on this.

P.S. - Just wondering why you went through all the apple scripting to do the Open Preferences> Variables macro?
If you could use KM steps.

You’re welcome.

The script just does one thing: Make the “Variables” panel/tab active.
I don’t know of a way to to that in KM using non-script actions. Do you?

Make the “Variables” panel/tab active.
I don’t know of a way to to that in KM using non-script actions. Do you?

Funny… this whole thread started by me trying to do just that.
Now that I know how to click a specific point relative to a specific window.
•Open / Check for the KM Prefs window.
•Set a Click or Move point to where the Variables tab is.

1 Like

Good idea! I completely overlooked that.

However, I still prefer the AppleScript solution. The KM Mouse click solution will break if the location of the “Variables” tab changes, whereas the AppleScript will continue to work as long as the button/tab is named “variables”, regardless of location.

There is no usually with tabs on macOS.  :wink:

The Cmd-# keyboard shortcut works with some apps like Safari and Chrome but is not a ubiquitous trait amongst tab-capable apps.

Try it in the Finder...

Clicking relative to a window is easy enough, as you've discovered — but it is unnecessary in this instance.

Show Keyboard Maestro Variables Preferences.kmmacros (2.9 KB)

Generally I prefer using System Events for this sort of thing, but Keyboard Maestro's Press a Button action can often get the job done.

Keyboard Maestro looks for an available button named <button name> and can be a bit slow if there are many buttons available, so it can be faster to directly address the specific button with System Events. You just have to test and see.


Another reason that I prefer the script that Chris wrote.

Thanks for point that out, Chris.
It is amazing what I don’t know, and learn about the Mac every day from the folks in this forum.