Relative vs. absolute mouse coordinates

When I set the coordinates for a Move and Click action relative to the Front Window's Corner or the Main Screen's Corner, I expected if the window or screen moves, the coordinates would move with it so the mouse moves and clicks in the same place relative to a corner. However, when the window or screen moves, the coordinates stay the same relative to their absolute position, not the window or screen position. Consequently, the mouse moves and clicks somewhere else in the window or screen than where I first intended.

What. do I not understand or am I doing wrong? Thanks

The action measures using the MAIN screen. What happens when you use 'Go' or 'Get' buttons within the action. What numbers are returned?

That doesn't sound right. Post your macro so we can see what might be happening.

tiff01

Again, the problem is when the main screen moves in a subsequent session, the numbers remain the same and the move/click does not occur at the correct position in the screen.

Maybe I just have to move the screen to its position when I set the coordinates. Otherwise, I don’t see any difference between using Absolute Position instead of Main Screen Relative.

What do you mean by "move the screen"? A screen can be thought of as the entire visible space displayed by a monitor. If, for example, you have only one monitor, then coordinates relative to its top-left corner are absolute coordinates.

It sounds like you want to use coordinates relative to a corner of the front window. The odd thing is that it sounds like you've tried that and it isn't working as expected. Is that correct?

Yes, that’s correct. If a window gets moved around on a screen, I would like to be able to move/click the same spot on a window, even when the same window moves somewhere else next time I run the macro. Maybe I just need to assure the window is moved back to its original position. Thanks for responding, I’m still pretty new to KM.

Sorry to keep asking for clarification, but...

The screenshot you sent was for clicks relative to the entire screen's corner. What happens when you set it to click relative to the front window's corner instead?

Is there a particular app you're having difficulty with or is it not working at all?

tiff01

Even without moving the front window, the pointer moves around from one spot to another in the window after the initial Get and Go. If the window is in a different place than it was with the initial Get and Go, the pointer is still nowhere near where I set it to begin with.

Here is the front screen I am working with. I first do a Get on the Sign On button. The Go works fine. But then when I execute the macro again, the pointer ends up somewhere else.

Here's one possibility:

You need to activate the target app before the Get timer runs out and the mouse position is captured as a coordinate. If not, then you're capturing a coordinate relative to the front window of the KM Editor.

I tried that and it has the opposite effect. It gives me the coordinates for the KM editor.

That's not normal. Here's what I do to get front window coordinates. Tell me if you're doing anything differently:

CleanShot 2023-04-30 at 18.21.34

I think, with your help, I finally got my problem with “front window relative” to work. But, one thing still puzzles me. I did as you suggested earlier with the Get command. After I issue a Get command, I tap the front window in Safari to make sure it is active. Then, I quickly move my pointer to the place where I want to get coordinates before my 5 seconds are up. All as you suggested. Before I was not getting the correct coordinates without making sure the window was active. This was a giant step forward for me.

However, the puzzling part which caused me some confusion and which might be helpful to others: when I issue a Go command after a Get, the pointer doesn’t go to the coordinates in the Safari window, but instead those in the KM editor. However, I ignored that and clicked “Run” in the KM editor or else ran the macro using a trigger, and everything worked fine.

I also noticed that, if after obtaining the correct coordinates, I tried to run the macro by selecting some of the actions in it and by right-clicking “Try n actions,” the macro failed, unless actions were included as you showed me in the video you sent.

Thanks again for your help.

BTW I really liked your little video. It was very helpful

1 Like

Yes, clicking Go while KM is at the front will find coordinates relative to the front application's front window, which at that time is KM.

It's a good idea to set up Run Current Macro and Try Selected Action hotkeys so that you can go to Safari and try your click action out, or indeed run your entire macro (without having to set a dedicated hotkey).

Hey Stephen,

Please don't post TIFF images to the forum. The only web browsers that can view TIFFs are the Safari-based ones, and those are a minority.

I fixed the ones you already posted.

You didn't notice the DM (direct message) I sent you?

Take Care,
Chris

(Keyboard Maestro Moderator)