Can others using Mac OS X 10.4.x confirm this bug in the Finder AS implementation? In previous versions of the Finder, and according to the current Finder’s AS dictionary, “zoomed” is a property of a window that can be read & set. However, I’ve found that it can’t be set, only read. To test, try this code:
tell application "Finder"
set the_window to make new Finder window
tell the_window
try
set zoomed to true
close
on error the_error
close
tell me to display dialog the_error buttons {"OK"} default button 1 with icon 0 giving up after 10
end try
end tell
end tell
Hmm, if you open a new window and then get the properties of that window, it will say that the zoomed property is already false but setting it to false via a script does cause the window to resize:
tell application "Finder"
set the_window to make new Finder window
tell the_window
try
get {zoomed, bounds}
-->{false, {5, 405, 1277, 786}}
set zoomed to false
get {zoomed, bounds}
-->{false, {5, 405, 470, 566}}
close
on error the_error
close
tell me to display dialog the_error buttons {"OK"} default button 1 with icon 0 giving up after 10
end try
end tell
end tell
Setting a value for a property that is the same as the current value shouldn’t cause any change to the item… I’m trying to update a bunch of Finder scripts for 10.4 compatibility and this is causing a major headache.
I posted the bug to Apple’s bug track service back in June but it was closed (one page says it was closed because it was a duplicate, another page simply says it was closed, no reason listed). There’s no way to find the duplicate issue posted by someone else to see how that was resolved (and, obviously, it hasn’t been). This bug has broken Finder Window Manager and made my life very frustrating just answering the barrage of emails berating me for not updating FWM for Mac OS X 10.4 compatibility.
Did you ever figure out a workaround? I guess I haven’t tried accessing the zoomed property of a Finder Window in quite a while, since I just ran into this bug today, and apparently it’s been around since 10.4 was introduced. Is there any clean workaround? My next thought is to try GUI scripting… but that’s not really very cool.
Model: iMac G5 (10.4.9)
AppleScript: 1.10.7
Browser: Firefox 1.5.0.11
Operating System: Mac OS X (10.4)
For the benefit of anyone encountering the same problem, here’s a handler that uses GUI scripting to effectively set the zoomed property (by clicking the zoomed button when necessary) of the frontmost Finder window.
setZoomed(true)
on setZoomed(n)
try
tell application "Finder" to tell Finder window 1 to set {c, zoomed} to {zoomed, n}
on error number e
if e = -10000 and n and not c then tell application "System Events"
if UI elements enabled then tell button 2 of window 1 of process "Finder" to click
end tell
end try
end setZoomed
It would be nice if Apple would fix this bug, but this is a workaround for anyone who runs into the same problem.
Model: iMac G5 (10.4.9)
AppleScript: 1.10.7
Browser: Firefox 1.5.0.11
Operating System: Mac OS X (10.4)