Copy the AppleScript Bounds Property of the Front Finder Window to the Clipboard


Macro: Copy the AppleScript Bounds Property of the Front Window to the Clipboard


Usage: Anytime you need to position a Finder window on your screen, first set the relevant window where you want it - then run the macro and you'll get the AppleScript bounds.

For example: {0, 32, 1153, 1174}

Should you need the bounds for a KM macro where you use "Move and Resize Window" you have to do some math (simple ~).

OR:

You can use the "Window Discovery Tool v1.0" = Window Information Tools

which collects information about every window and then displays this information in a table in TextEdit. The values acc. to KM's own measure.

See this explanation:

Here is the Macro in question, thanks to Chris S @ccstone

Copy the AppleScript Bounds Property of the Front Window to the Clipboard.kmmacros (2.5 KB)

Macro Image

1 Like

Even simpler -- use the %WindowFrame%Front% token :wink:

AppleScript's fun, but why overcomplicate things?

Because they don't produce the same output?

KM Window Frame:

228,23,1314,1173
left,top,width,height

AppleScript Bounds

{0, 23, 870, 520}
{X1, Y1, X2, Y2}
{Left-Top-Corner, Right-Bottom-Corner}

The confusing part of this is that System Events UI-Scripting does not use bounds – it uses position, width, and height similarly to Window Frame.

For scriptable apps its more efficient and more organic to operate their windows directly with bounds than to drive the UI, but learning to do that isn't for everyone.

@okn was suggesting people use AppleScript to get the bounds, then do some maths to calculate the values to use in a KM action. I'm saying just use KM to get the values to use in a KM action...

3 Likes

Boy, that went right by me... I need lunch and coffee.

Okay, I'll bite...

Window List with Window Frame of Front Application v1.00

1 Like

Nice!

1 Like