Move cursor between monitors

I am making a marco which I press hotkey, it will move mouse cursor to next monitor

So far, I can use ‘Move Mouse’ and give SCREEN(1, MidX) and SCREEN(1, MidY) to let my cursor move to mid of main screen.

How could I alway move my mouse cursor to next monitor within same marco?

Thanks.

How many monitors do you have? If you have two, then you can do something like:

If MOUSEX() > SCREEN(1,Right)
    Move Mouse to SCREEN(1,MidX),SCREEN(1,MidY)
Else
    Move Mouse to SCREEN(2,MidX),SCREEN(2,MidY)

If you have three, you can do the same sort of thing but a bit more of it.

For bonus points, you could check if the mouse is near the center of the screen first and only then move it to the next screen, something like:

If MOUSEX() > SCREEN(1,Right)
    If ABS( MOUSEX() - SCREEN(2, MidX) ) < 10 and ABS( MOUSEY() - SCREEN(2, MidY) ) < 10
        Move Mouse to SCREEN(1,MidX),SCREEN(2,MidY)
    Else
        Move Mouse to SCREEN(2,MidX),SCREEN(1,MidY)
Else
    If ABS( MOUSEX() - SCREEN(1, MidX) ) < 10 and ABS( MOUSEY() - SCREEN(1, MidY) ) < 10
        Move Mouse to SCREEN(2,MidX),SCREEN(2,MidY)
    Else
        Move Mouse to SCREEN(1,MidX),SCREEN(1,MidY)

So it would move first to the center of the screen it is on, and then on the next call to the center of the other screen.

You might like to add a Highlight Location action to show where it is.

I’m interested in creating this macro, but I don’t know where the “SCREEN(1, MidX) and SCREEN(1, MidY)” action. I found the Move Mouse action, but I don’t see how to put the SCREEN action in there.

SCREEN is a function, not an action. You can use them in any calculation field (see Text Fields in Keyboard Maestro).

Eg:

1 Like