Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > macOS > Resize a Window to Huge Dimensions With AppleScript.

Resize a Window to Huge Dimensions With AppleScript.
Thread Tools
red rocket
Mac Elite
Join Date: Mar 2002
Status: Offline
Reply With Quote
Feb 25, 2008, 08:59 AM
 
I sometimes feel the need to resize a window beyond my screen size.

The most typical occasion involves wanting to take a Finder window screenshot of a folder with hundreds or thousands of files in it, like for this thread from a year ago.

(The way I used to do it was to take multiple screenshots and stitch them together. Another MacNN member, Mithras, resized the window using a third party piece of software called MondoMouse. Both these approaches have flaws. Mine takes too much time, the other one involves $15 shareware that doesn't work on pre‑Tiger systems.)

Anyway, after spending futile hours looking for alternatives, I came across this thread on macosxhints about resizing windows to their vertical maximum. The method involved the following AppleScript by some guy called jdsmith:

[codex]
set display_y_size to 854

set cur_app to (path to frontmost application as Unicode text)
if cur_app ends with ":Finder.app:" then
set Finder to true
tell application "Finder"
set tool_vis to toolbar visible of front window
end tell
else
set Finder to false
end if

tell application cur_app
tell front window
set {x1, y1, x2, y2} to (get bounds)
if Finder then
-- Finder uses inside of frame for bounds, not counting toolbar
if tool_vis then
set y1 to 83
else
set y1 to 44
end if
-- Explicit y size of your display
set y2 to display_y_size - 5
else
set y1 to 22
set y2 to display_y_size
end if
set bounds to {x1, y1, x2, y2}
end tell
end tell

[/codex]

The interesting bit is the first line, where Smith set the vertical size of his display as 854 pixels.

You can set that bit to any value you like. In my case, I set it to 9000 pixels, which gave me plenty enough space to capture a Finder window in list view with around 300 items in it. Just paste the script into Script Editor, adjust the one value, save the script somewhere convenient, and whenever you run it, your frontmost window will be resized to any vertical height you like. Afterwards, you can just take a screenshot of the window with Command‑Shift‑4, Space, you'll get a pic of the complete content.
     
bkruepl
Fresh-Faced Recruit
Join Date: Apr 2008
Status: Offline
Reply With Quote
Apr 3, 2008, 08:08 PM
 
I would like to do the same with Safari, but I can't set
the window bounds beyond the screen limits.

Any ideas?
     
red rocket  (op)
Mac Elite
Join Date: Mar 2002
Status: Offline
Reply With Quote
Apr 4, 2008, 07:07 AM
 
[codex]
tell application "Safari"
activate
set the bounds of the first window to {0, 0, 6000, 6000}
end tell
[/codex]

This would resize the frontmost Safari window to 6000 by 6000 pixels, for instance.
     
zro
Mac Elite
Join Date: Nov 2003
Location: The back of the room
Status: Offline
Reply With Quote
Apr 4, 2008, 09:57 AM
 
What do you need a screenshot of a Finder window that long for?
     
bkruepl
Fresh-Faced Recruit
Join Date: Apr 2008
Status: Offline
Reply With Quote
Apr 4, 2008, 11:43 AM
 
The strange thing is, this code resizes the window to 6000 pixels in width, but only to my maximum screen resolution in height (Safari 3.1, Leopard).

For web pages, increasing the height would be much more useful!

Any ideas?
     
red rocket  (op)
Mac Elite
Join Date: Mar 2002
Status: Offline
Reply With Quote
Apr 5, 2008, 04:30 AM
 
Originally Posted by zro
What do you need a screenshot of a Finder window that long for?
Like I explained in the original post, ‘pics of your 3rd party applications folder’ type of threads.

_________________________________
Originally Posted by bkruepl
The strange thing is, this code resizes the window to 6000 pixels in width, but only to my maximum screen resolution in height (Safari 3.1, Leopard).

For web pages, increasing the height would be much more useful!

Strange, it works as expected with Safari 1.3 and Panther. (Could someone check whether it works in Tiger?) Odd thing for Apple to break, the code is so basic.

Any ideas?
Sunrise Browser can take page shots. Free, Leopard‑compatible.

SnapWeb can also do it, is compatible with Leopard, but costs $17.90. NetFixer and Paparazzi! are free, but haven’t been updated.
     
bkruepl
Fresh-Faced Recruit
Join Date: Apr 2008
Status: Offline
Reply With Quote
Apr 6, 2008, 07:41 PM
 
I found out what the reason is.

After I found out that Terminal.app has the same problem, I realized that all Cocoa apps are affected.

Some investigation revealed that "whenever a titled NSWindow object is placed onscreen and whenever its size is changed", "the rectangle’s height is adjusted to fit within the screen as well." See the NSWindow Class Reference.

Since this can be overridden, I am going to write a SIMBL plugin to do exactly that.

red rocket, thanks a lot for your other suggestions. I compiled a little tool survey in my blog, maybe it's useful for somebody.
     
Sal
Dedicated MacNNer
Join Date: Sep 2000
Location: Cupertino, CA USA
Status: Offline
Reply With Quote
Apr 19, 2008, 11:16 AM
 
On a related note, Apple has posted a free one-click script that zooms the frontmost Finder window to fill the screen while displaying in Flow View. One more click and the window returns to normal size and view!

Available here.
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 10:44 AM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,