Create If Then Else condition based on mouse location and cursor type?

Is it possible to create a condition that returns true based on the mouse position on the screen (for example if the mouse is on the bottom half of the screen) or if the cursor has changed to all-scroll (Tryit Editor v3.7)?

So my goal is to have one of these true:

  1. Either the mouse is on the bottom half of the screen or
  2. The cursor has changed to all-scroll
    If one of them is true, then it goes to the next action

As you know, the first is (relatively!) easy -- we used pointer positioning in the "move window to top to resize" macro.

For the second -- it depends on what app you are using. The fact that it's a CSS property (unless you are just using that page to show what the cursor looks like?) implies a web browser, so you should be able to JavaScript query the current cursor property. If anything else you'll be better off looking for something else that changes when the cursor does -- maybe the availability of a particular menu item.

I've no idea about the cursor condition, but this is how to do the first bit:

1 Like

Ok I gotta revisit that and see if I can apply it to this other macro I'm building.

Not possible at all. This is just an audio editor and when you hover over a certain area of the audio, it changes to the all-scroll icon

Awesome! That's working. Thanks! :slight_smile:

Question: if I wanted to set a particular location, instead of just half of the screen, let's say "639px" as my divider, how would that change the calculation?
I tried this calculation and I see that it no longer defines the middle as the divider:
MOUSEY() < SCREEN(Main,MidY)+300
Is this how to do it or is there a way to set the exact value?

Then unless there's a way to query the application itself (eg AppleScript), I think you're stuffed. For example, KM's Image Detection would only stand a chance if the pointer image was a square/rectangle and had a solid, unchanging, background.

If you want to use absolute coordinates for the mouse positioning, just type them in: MOUSEY() > 639 -- the function @noisneil used to determine the middle of the screen is so you can use the middle whatever size your main screen is at that moment, so you can easily use the macro on different machines or monitor configurations.

I have no clue about that and AppleScript is not my strength at all...
I wish KM would detect images with transparency, because that would make everything easier.

Will save this info in case I need this type of calculation. Thanks!

Yes, in this case I need a divider. So it's not that I need it to do something at exactly 639px. I want that to be a divider so if the mouse is above that number it does one thing, if it's below, it does another thing. That way I will be able to work around some of the issues, because when the cursor changes, it's always a little bit below the middle of the screen.

This sets the portion of the screen the mouse can be in to satisfy the condition to:

The top half plus 300 pixels below the midpoint.

My screen is 1200px tall, so the midpoint will be 600px. In this case, setting the border to 639px means I'd use:

MOUSEY() < SCREEN(Main,MidY)+39

Ok so you're saying that the calculation I shared, is how you would do it?
I saw in the Wiki documents that instead of MidY we can use Height, but I don't know how to add a specific value to that. When I tried to add numbers, the calculation turned red. Is it possible to set a specific number instead of the +39 (or whatever number I need)?

It's one way, if you want to offset from the mid-point, but @Nige_S has given you the best way to set the border to an exact pixel height with...

This is the bit you need to define more carefully -- KM has no concept of "a little bit" :wink:


  • Screen coordinates start at (0,0) in the top-left corner and get bigger as you head right (the first number) and down (the second)
  • You can get the horizontal middle of your main screen with SCREEN(Main,MidY)
  • If "a little bit" below that is 15 screen coordinate units, you've now got SCREEN(Main,MidY) + 15 (numbers get bigger as you go downwards, which is why you are adding)
  • Now you have a number to compare the pointer position to: MOUSEY() > SCREEN(Main,MidY) + 15, which returns "true" if the pointer's Y coordinate is greater than the screen's horizontal middle plus another 15 units

In plainer English, "Is my pointer lower than 15 units below the middle of the screen?".

I hope I'm not belabouring the point. I'd be totally lost listening to you guys talking about "scrubbing high BPMs through a pitch-shift wow-wow", or whatever it is you get up to :wink: -- but, like most things, once you've got the fundamentals and some of the jargon you'll find things a lot easier to understand.

Wow, spot the noob. Everyone knows only low-to-medium BPMs can be scrubbed through a pitch-shift wow-wow.

1 Like

My bad, I thought that was something different when I looked at it, because I thought I needed to add that to the other calculation with the SCREEN sizes, etc.
It's working now.


Yes, I got that logic of the middle of the screen before, but I was looking for a fixed number. When you suggested the MOUSEY() > calculation, I thought it was something else. My bad. It's working now :wink: Thanks!