|
|
Resize a Window to Huge Dimensions With AppleScript.
|
|
|
|
Mac Elite
Join Date: Mar 2002
Status:
Offline
|
|
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.
|
|
|
|
|
|
|
|
|
Fresh-Faced Recruit
Join Date: Apr 2008
Status:
Offline
|
|
I would like to do the same with Safari, but I can't set
the window bounds beyond the screen limits.
Any ideas?
|
|
|
|
|
|
|
|
|
Mac Elite
Join Date: Mar 2002
Status:
Offline
|
|
[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.
|
|
|
|
|
|
|
|
|
Mac Elite
Join Date: Nov 2003
Location: The back of the room
Status:
Offline
|
|
What do you need a screenshot of a Finder window that long for?
|
|
|
|
|
|
|
|
|
Fresh-Faced Recruit
Join Date: Apr 2008
Status:
Offline
|
|
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?
|
|
|
|
|
|
|
|
|
Mac Elite
Join Date: Mar 2002
Status:
Offline
|
|
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.
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.
|
|
|
|
|
|
|
|
|
Fresh-Faced Recruit
Join Date: Apr 2008
Status:
Offline
|
|
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.
|
|
|
|
|
|
|
|
|
Dedicated MacNNer
Join Date: Sep 2000
Location: Cupertino, CA USA
Status:
Offline
|
|
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 Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|