Can Changing The Screen Resolution Sabotage Macros?

I have aniMac27"-5K and my macros works fine here, using native resolution for screen. I have just gotten the new Mac Mini M1, and uses it with an LG HDR 4K (3840 x 2160). Right now I have scaled the display for 'more space' rather than 'larger text'. So my question is if I copy my macros from the iMac, and make them work in one screen resolution, will they still work if I change resolution for screen?

I use a number of instances like this to make the click happen correctly, so I wonder if the selected part of the screen + offset distance will 'change appropiately' when I thange screen resolution, or...???

Palle
image

You are quite likely to have poor results in webpages but you might get lucky in some apps as they’re more likely to use consistent resolutions for elements

There are plenty of options for modifying your macros to make them more reliable across different screens though. Just depends on your exact macros

I have tried out different settings, and most macros will work, after some local adjustments. This can be in the offset coordinates from the selected screen picture and also by trimming the fussiness slider. Found out there are no exact way to do it. seems it depends on the brightness of the screen too. (but all are in 'Light' mode).
One unexpected thing came up, after I had tried changing the screen resolution and reverted to the previous size. I cannot say it is an absolute finding, but what I experienced was that some of the basic macOS placements had changed.--->
like using "Format/color" will have Big Sur place a small palette in lower left side of screen, but that placement had shifted upward a bit so instead of text getting black, as expected, it turned out green. the fix is using some tape and place on screen marking the correct place, and then from KM using "Get" to the marking on the tape. (these small boxes evaporates once you return to editing in KM) anyway. I am fairly satisfied as of now.
should anyone have a question led me know
P

If you need to find in Dark mode, this macro helped

I'm trying to build a macro set that takes these steps to solve this problem:

First, a Global Macro that looks like this:

Trigger: Focused window changes
Actions:

  1. Screenshot the Front Window to the System Clipboard
  2. Get image pixel width from the System Clipboard to variable
  3. Get image pixel height from the System Clipboard to variable

Second, a macro that is used for a specific application and targets mouse clicks based on the resolution values from the above macro.

Trigger: [Use your imagination]
Actions:

  1. Set Variable xHorizontalx to Calculation ROUND(width*[percent of screen width that matches click target])
  2. Set Variable yVerticaly to Calculation ROUND(height*[percent of screen height that matches click target])
  3. Set Variable xyTargetxy to Calculation xHorizontalx, yVerticaly
    4.Use Variable xyTargetxy to Set the Mouse Location

Guess what the trouble is? Yep, you guessed it. I haven't found a way to use a variable to set the mouse location that isn't absolute. What I need is to be able to use the caclulated values in the other mouse action that actually includes a reference for the movement. If I could set the reference for the mouse target relative to the front window's corner it would be a slam dunk. it wouldn't matter what the size or resolution of the window is and I could use more intuitive percentage values to target the mouse.

Maybe you've solved this and I'm just missing the mouse macro to rule them all. If you have any ideas, please let me know.

Thanks and don't forget to have a great day!

There's more info about the various "Move or Click Mouse" action's options, including "Location Relative To", on the wiki page.

Why are you doing this? If you want the width and height of the front window, ask the front window :wink:

Loads more about Window tokens on the wiki.

Put the above two together and you'll see it's really easy to eg "click 20% of window width and 30% of window height from the top left corner of the frontmost window".

1 Like

Nige_S - I'm glad you're here helping me out with these new tools I'm learning. I've added a Global Kill Switch to my tools to avoid painting myself in the corner again. ; )

Are you saying I can use a variable in the Move Mouse action? I tried that first and it didn't work. Maybe I haven't figured out how to use variables correctly.

Yes, you can. A variable, a token, a function, a calculation, a mix of those -- anything that resolves to a single number.

Here's an action that puts the pointer in the middle of the front window, using a function:
moveMouseToWindowMiddle

WINDOW is a KM Function that returns information about a window's position. 0 means "the frontmost window" and MidX and MidY mean "the coordinate of the horizontal middle" and "the coordinate of the vertical middle" of that window.

WINDOW returns absolute position, in nominal display pixels starting from (0,0) at the top-left corner of your main screen. Because of that the action uses "relative to the absolute position" so it also starts "counting pixels" from the top-left corner.

Without seeing your attempt -- post your macro if you want more specific advice -- it's difficult to say what the problem is. But have a read of the Variables section of the manual to find out more about types and how to set and use variables. The Text and Numeric Fields wiki page will also help (eg the explanation about how numeric fields magically expand when you put in anything other than a simple number).

And then you'll want to look at tokens, functions, calculations... OK, that's starting to get a bit overwhelming! But if you start with the general concepts in the manual you'll soon know where to go and what to look for there or on the wiki, and you can just let the specifics seep in to your brain as you need them.

But don't let that put you off asking here -- if you're ever stuck on something there's always people willing to help.

1 Like