10

I'm wondering whether there is a way to write code for Mac OS 10.5 which will minimize and restore a window. What language would it be in? Could someone please give me an example or direct me to documentation on Apple's developer site I should look at?

Thanks!

Vivek Subramanian
  • 1,174
  • 2
  • 17
  • 31

4 Answers4

15

Try this applescript:

tell application "Safari"
  set miniaturized of window 1 to true
end tell
Christoph Lupprich
  • 1,170
  • 8
  • 16
  • works great. Asides each app has their own set of properties that we can set, for example for Chrome it's `minimized` instead of `miniaturized`. We can use Script Editor app to load the target app, and take a peek inside `scripting.sdef` file. I adapted from discussion about this at https://discussions.apple.com/thread/8351320. – haxpor Feb 07 '19 at 17:18
0

Apple | AppleScript

AppleScript is Apples native scripting language. The official link above includes very useful information on how you can get started.

I suspect that the following URL is what you may need. It provides information and sample code for scripting and automation in AppleScript: AppleScript | Scripting and Automation

0

I had trouble with these working in 2023.

This worked for me to open chrome and then minimize.

   tell application "Google Chrome"
       activate
       delay 1
   end tell
   tell application "System Events" to set visible of process "Google Chrome" to false
Mike Averto
  • 655
  • 1
  • 10
  • 16
  • Note that this hides an app—not minimize a window. Many apps can't be hidden, but their windows can still be minimized (e.g. background apps with pop-up windows that don't show up in the Dock) – huyz Aug 26 '23 at 10:54
0

I wanted to start Mail on login, but without window preview on left side of trashcan icon on at Dock. This solution does not work for most applications, but it works perfectly for Mail.

tell application "Mail" to close window 1

This opens Mail on logon, and then closes the window, which leaves Mail running (check small dot below Mail's icon on dock) to background. In case that you did check re-open windows when you login again while logging out or rebooting, and you left your Mail window to front, not closed, this will re-close it, in case you set this as one of your Login items. This has been asked on Apple's forums as well without proper solution.

enter image description here

I saved it to Applications with name MailHidden and made it a nice dark icon in case someone wants to follow this, I included it below.

enter image description here

Originally I found it with Google's image search while looking for proper Mail icon, there was a site that talked about Apple's new Mail icon and had nice image there that I slightly modified to look like night mode of Mail icon.

jake1981
  • 303
  • 3
  • 11