Maximize, not just "zoom"

I noticed that in OS X, the “zoom” option toggles a window between larger and smaller. I need a macro to make it larger via zoom, unless it is already larger in which case do nothing. I am new to OS X and having trouble finding directions for doing this even using OS X manually – I can find references to setting up a keyboard shortcut for the TOGGLE action of zoom, but not something that ONLY maximizes.

To take a step back and ask why I am doing this, it is because I am trying to record macros with mouse clicks and I want to be sure the layout of the app’s window is in a consistent state before running the recorded macro. If there is a better way to do this, let me know.

.
Interesting question from mike1127.
I, too, use OSX zoom function.

OSX hot keys are in Apple menu / System Preferences / Accessibility / Zoom

You don't need KM to use those, but KM will make it easier.
To get consistent magnification each time, use KM action, "repeat", and specify something like: zoom-in 5 times.

I hope this is helpful to you.
Anything not clear, please don't be shy to ask.
.

I think he’s speaking of the Window Zoom:

This AppleScript basically does it:

tell application "TextEdit"
  tell window 1
   set zoomed to true
  end tell
end tell

To always call the frontmost application replace the first line with…

tell application (path to frontmost application as text)


I say “basically”, because it doesn’t work with all applications (for example Safari, which always reports “zoomed” as true).

Maybe one of the AppleScript experts here can help.

Heck, I just found out that you can achieve the same with the KM action “Move and Resize Front Window”, by setting it to “Full Screen”:

…and it seems to work with all apps.


@peternlewis: I find the terms in that action a bit misleading:

  • KM’s Zoom does what Apple is calling Enter Full Screen (View menu)

  • KM’s Full Screen rather does what Apple is calling Zoom (Window menu) :thinking:

1 Like

To make it more confusing, in Google Chrome, Window > Zoom does nothing:

But then there is the View menu:

where "Enter Full Screen" does just that.
"Zoom In" / "Zoom Out"/ change the magnification on the page.

I'm running Chrome 53.0.2785.143 (2785.143) on macOS 10.11.4.

Funny, in Chrome 46.0.2490.80 it is still correct:

(The “Enter Full Screen” is at the bottom, where it belongs to.)

Also the “Zoom” (Window menu) still works in Chrome 46.0.2490.80.

The “Zoom in” / “Zoom out” for magnification change is Apple standard, as far as I know.

That is because Apple changed their behaviour.

The Keyboard Maestro "Zoom" action does an accessibility press on the kAXZoomButtonAttribute, which is basically the same as clicking the green button in the window, which used to zoom to full size, but Apple changed to do Enter Full Screen.

I find it difficult to change this "Zoom" action name to "Enter Full Screen" while performing the accessibility action on the kAXZoomButtonAttribute and I don't know what Apple might do next week.

The Full Screen window resize resizes to the full available screen area, it is not related to Full Screen Mode in the same way that you cannot manually resize a window to Full Screen Mode.

Yes, since 10.10 you can both access with the green button: click → Full Screen, ⌥click → Zoom.

Unfortunately, I don’t believe the accessibility API has the concept of option-clicking.

Probably not, but the green button has two accessibility actions: AXPress (= full screen) and AXZoomWindow (= zoom).

This does the same as a single click:

tell application "System Events"
  tell (first application process whose frontmost is true)
    tell front window
      tell (first button whose subrole is "AXFullScreenButton") --button 2
        perform action "AXPress"
      end tell
    end tell
  end tell
end tell

This does the same as an Option-click:

tell application "System Events"
  tell (first application process whose frontmost is true)
    tell front window
      tell (first button whose subrole is "AXFullScreenButton") --button 2
        perform action "AXZoomWindow"
      end tell
    end tell
  end tell
end tell


But my initial comment wasn’t about the functionality of the KM action, it was just about the naming Zoom vs Full Screen.

Not a problem, I know now how to read it :wink:

2 Likes

Thanks, Tom and Peter. That did the trick for me!**

The option-click AppleScript didn't work for me in Monterey. This did:

    tell application "System Events"
        perform action "AXZoomWindow" of (first button whose subrole is "AXFullScreenButton") of (first window whose subrole is "AXStandardWindow") of (first process whose frontmost is true)
    end tell

and for narrower display one might be tempted to turn that inside out:

tell application "System Events"
    tell (first process whose frontmost is true)
        tell (first window whose subrole is "AXStandardWindow")
            tell (first button whose subrole is "AXFullScreenButton")
                perform action "AXZoomWindow"
            end tell
        end tell
    end tell
end tell