Here are two one-line scripts I wrote to keep in my system script menu.
Minimize Others
This mimics the behavior of the Mac OS “Hide Others” feature except in this case “Others” does not refer to other applications, but refers to other windows of the current application. I realize you can option-click minimize to minimize all windows, but then you’d have to go hunting for the window you were using, which just isn’t cool.
tell application (path to frontmost application as string) to copy true to the miniaturized of every window whose visible is true and miniaturizable is true and name is not name of window 1 as string
Maximize Window
This script mimics the behavior of MS Windows gasp maximize window feature. Because sometimes ‘zoom to fit’ just isn’t big enough.
tell application (path to frontmost application as string) to copy (run script "tell application \"Finder\" to desktop's window's bounds") to bounds of window 1
(OK I cheated a little on the one-linedness of that last one ;))
Disclaimer: Now I get to tell you that these probably won’t work in every application. They usually work ok in scriptable applications that contain the ‘Standard Suite’, which should include most new apps these days.
To get the screen size (taking the menu bar into account) use:
{word 3 of (do shell script "defaults read /Library/Preferences/com.apple.windowserver | grep -w Width") as number, (¬
word 3 of (do shell script "defaults read /Library/Preferences/com.apple.windowserver | grep -w Height") as number) - 22}
This will ignore the dock unfortunately. I just can’t get your script to work, silvermeteors.
edit: BTW, I think this script was originally from MacOSXHints.com
This script works with MY two monitors (dual display) setup. but only sometimes. I’m hoping someone can improove upon it since there does not seem to be an end all be all solution to making a window as big as the monitor it is on.
set Dimentions to (do shell script "system_profiler SPDisplaysDataType | grep Resolution | awk '{print $2, $4}'")
set displayWidth to word 1 of Dimentions
set displayHeight to word 2 of Dimentions
set display2Width to word 3 of Dimentions
set display2Height to word 4 of Dimentions
tell application (path to frontmost application as string)
set windowBounds to bounds of window 1
if item 1 of windowBounds < displayWidth then
set bounds of window 1 to {0, 0, displayWidth, displayHeight}
else
set bounds of window 1 to {displayWidth, {displayHeight - display2Height}, {display2Width + displayWidth}, display2Height}
end if
end tell
please!!! someone write this script for us!
=]
Another post that needs the screen resolution! When will Apple make this directly available? http://bbs.applescript.net/viewtopic.php?id=24172
That script is great but i need one that will minimize all windows except for one titled “weathermap.jpg”. i know it seems simple but i havent ben able to figure it out. all i have is his that minimizes everything even non scriptable apps.
tell application "System Events"
set theButtons to {}
repeat with theApplication in application processes
repeat with theWindow in windows of theApplication
repeat with theButton in buttons of theWindow
if ((description of theButton) is "minimize button") then
set theButtons to theButtons & {theButton}
end if
end repeat
end repeat
end repeat
repeat with theButton in theButtons
click theButton
end repeat
--do it twice because it usually misses one the first time
repeat with theButton in theButtons
click theButton
end repeat
end tell
if you could help me it would be highly appreciated.