How to use frontmost application window dimensions as a condition?

I created a macro to resize the frontmost application window when it activates. It is working well, but I would like the macro to work only when the frontmost application window dimensions are different from the ones when the window has been resized.

I have tried with the FrontWindowFrame token but didn't find any valuable solution.

As long as you're using the right token (%WindowFrame%1%) and the right notation, there shouldn't be any reason why this couldn't work:

Example Macro.kmmacros (2.5 KB)

Thanks @gglick.

Found the problem comes the way the macro is triggered. When I select "iTerm 2" in macro group and in macro settings, I get a yellow flag telling me the macro will not be triggered.

I moved the macro to the "Global macro group". The macro is now triggered.

The macro now has the following logic. If Window Frame 1 is 420,10,600,900 do nothing, if not, move and resize Window Frame 1 to 420,10,600,900. The macro is triggered when the application iTerm is activated.

What I do not get is that KM shows the condition is always false. If the condition is not met then the window is resized so the condition should be true then, no?

That's because you're looking at the macro in the KM editor, and the window frame token is giving you that window's frame data. If you open iTerm but keep the KM editor window visible in the background, you should see the condition change to true.

Sure I knew that. That's why I founded even weirder the condition staying the same.

But how do you explain that this macro always displays "2".

Instead of displaying 1 or 2, try displaying display the actual value of %WindowFrame%1%. That should tell you what's going on.

1 Like