Shortcut to cycle move window, need help

I have four macros that move window to top left, top right, bottom left, bottom right. Each of them works fine. I wanted to add new shortcut to cycle through those 4 when processed the shortcut key continuously. Screenshot attached. All 5 macros are imported and attached as well.

It almost worked, except that when the window is at top right, it doesn't move to bottom left according to the switch logic. Can anyone help me check what's wrong with the macro? Thank you!


window 1:4 Macros.kmmacros (11.4 KB)

Can't help you without having Macro "3. 1/4 bottom left".

However, you can easily help yourself. :wink:

First use the Macro Debugger to step through your macro and make sure it is switching as you expect.
Second, trigger the Macro 3 indepently and make sure it moves the window as expected.

EDIT:

Two more thoughts:

  1. What is purpose of the "ROUND" function in your Set Variable "v1" to "v3" ?
  2. Try using the "is" operator instead of the "contains" operator in the Switch Cases.
1 Like

I think all four macros are included in the attachment. Yes all four macros works well if trigger them separately.

I use round because sometimes the value is decimal, while the winframe seems always integer for the coordinates

As @JMichaelTX suggests, add Debugger Breakpoint This Macro action before the Switch action and use the Value Inspector to inspect the value of the WinFrame and v1,v2,v3 variables.

I would guess that the values of v1,v2,v3 do not match the result of winFrame and that needs to be resolved for your macro to work properly.

1 Like

Thanks for the idea using different operator! I changed to use "starts with" and all works fine now!

v1,v2,v3 do match the result of then winFrame, still not sure why "contains" operator didn't work, but "starts with" worked.

1 Like

If starts with matches, contains should definitely match, so I'd guess something else was going on that you also corrected.

That's what I thought too, starts with is part of contains. However I tested multiple times without any other change, starts with works while contains doesn't work (doesn't move to bottom left), how weird this is.

Ah. That's actually kind of funny. I see why it is failing for you. I tried it out, and the first press works, and the second press works, but then it gets stuck and the top right, and so I logged the value of WinFrame, v1, v2, v3 and get:

“1280,23,1280,709” “0,23” “1280,23” “0,732”

But note:

“128==0,23==,1280,709” “==0,23==” “1280,23” “0,732”

So WinFrame does indeed contain v1, even though that is not at all what you want.

2 Likes

wow, exactly. and it stuck on bottom right too for the same reason!

thanks!

1 Like