Macro that circles through center of screens

Hello everyone!

I have only been able to get the center of the main screen but not the center or get to the center of the 2 other monitors I have. Can anyone help me with this? Ideally I would like to have macro that can circle through the center of each the screens. I occasionally have a 3rd monitor and I would like to be able to do that one too.

With the current macro that I have only gets me to the main screen but I still have to move the mouse to one of the other monitors and it has become kind of annoying. Thank you everyone for your help!

Totally untested, as I only have one display, but:

  • You can get the number of screens using the SCREENCOUNT() function
  • You can get the screen the mouse is currently on with the SCREEN(Mouse, Index) function

So you should be able to jump to the centre of the next screen -- next goes left-to-right (and, I think, top-to-bottom) -- with something like:

Next Screen Test.kmmacros (3.4 KB)


I'd love to know if that works!

This only works on one of my monitors. I set the hotkey: hyper key + G and it doesn't cycle through. What should I do?

Edit: Turn out it works! Thank you so much!

Read this just after I'd got home, set up a second display, and got ready to test...

Do you know what the issue was first time round?

If anyone's got 3 or more displays, I'd love to hear if the logic's sound in those situations too. Also if the top-to-bottom indexing assumption for vertically-stacked displays is correct.

I'm not entirely sure what it was that went wrong the first time. I recreated the macro step by step to understand how it works (still a little confused :laughing:) but it worked after I remade it.

I have connected the other displays I had and it worked perfectly! I had 4 displays.

With which bit?

If you know how many screens you need to cater for then the macro is easier -- so , for 3 screens, "If I'm on screen 1 then go to the middle of screen 2, if 2 then go to middle of 3, if 3 then go to middle of 1". We're taking advantage of screens being indexed 1..n, left-to-right.

Problem is that they don't wrap -- you can't do "screen 3 + 1" and go to screen 1 -- and we don't know how many "If"s to do if we don't know the number of screens in advance. So we have to work things out at runtime. I've brain-farted and over-complicated things by using the MOD function -- "modulo division", or "just get the remainder" -- and this version is probably clearer:

So "Get the index of the screen the pointer is on and add 1, saving as Local_nextScreen. If Local_nextScreen is greater than the number of screens, set it to 1 (our 'wrap-around' from eg screen 3 back to 1). Move the mouse to coordinates MidX, MidY of screen index Local_nextScreen."