I've just completed a set of macros that work perfectly on my large monitor. The macros click specific areas of the screen in a specific app. There are times when I'll be traveling with my MacBook Pro and want to be able to have similar functionality on the smaller monitor of the laptop. I can't figure out how to have KM learn screen locations for a click on the laptop while I'm working on my larger monitor. I'm hoping I can do the programming of the macros on the large monitor.
The answer may depend upon what specifies the location of the click.
If the click is always in the same place (say, relative to a corner of the application's front window), you should be able to scale the X and Y values for when the macros are running on the MacBook Pro‘s built-in screen.
For instance, have variables local Xscaler
and local Yscaler
, which both equal 1 for the big screen but which equal a different value for use with the small screen. That value is the multiplier for the X or Y value.
You could use the %ScreenResolution%
token to determine which monitor is in use, and set the scaler values dependent upon that.
If, however, the “specific area” relies upon detecting an image, the challenge is greater. I don‘t have time to read through it right now, but it looks as though this discussion would be illuminating on that topic.
Generally there are several approaches.
- Use coordinates relative to screen or window corners such that the coordinates work for both screens.
- Use SCREEN or WINDOW functions to calculate positions (eg
SCREEN(1,Left,40%)
). - Determine which Mac or screen it is (using the
SCREEN(1,Width)
function or otherwise, and then use If Then Else actions to choose between different coordinates)
It is true that for most purposes, there's no way to know the coordinates on another screen using coordinates from the first screen. For one thing, the second screen may not even have the same proportional shape as the first screen. For another thing, there's the macOS system menu which appears on only one monitor.
We don't know your particular screen sizes, nor do we know what things you are trying to click on, but in the rare event that the things you want to click on are in the exact same "percentage location" on each screen (eg, 50%,50%, which is the middle of the screen) then it is possible to use variables or formulas to move the cursor to the same percentage location on each monitor.
To demonstrate this I wrote a short macro that moves the mouse to the same "percent location" on each of my two monitors, and it draws a bullseye on each location. It may not serve a very practical purpose, but it does show that, if the conditions are right, with the right code, you can write a macro that handles two monitors at the same time.