Friday, December 15, 2017

#1 2002-02-24 02:43:06 am

Trash Man
Sanitation Department
Registered: 2005-10-20
Posts: 5336

A cry for help/Possible OS X Finder or AS bug?

I've been working around a strange bug in the Mac OS X Finder with an
AppleScript for quite some time now. Most users don't notice the bug at all, but
I do. Rather than describe it, follow these steps and see it for yourself:

1. Make a new Finder window
2. Set its view style to column
3. Adjust the column width/s with the slider, making them wider together
4. Leave the window open and log out
5. Log back in

At this point, your window will be open, but its columns will be at their
default widths.

6. Close that window
7. Open a new Finder window (should default to column view now)

Now, you'll see your custom widths respected. It just seems to affect the first
window you make or see that's in column view.

This bothers me, honestly, and I wrote a tiny--and really
dim-witted--AppleScript to get around the problem. Here it is (works best when
run at login automatically):

Applescript:

on run
tell application "Finder"
if (count of windows) is greater than 0 then
-- do nothing
else if (count of windows) is equal to 0 then
set fix to (make new Finder window)
close fix
end if
end tell
end run

As I said, it's not a smart script at all. If you have columned windows open, it
leaves them there for you to deal with. Wanting to make the script smarter, I
came up with this:

Applescript:

on run
tell application "Finder"
if (count of windows) is greater than 0 then
set daWindows to (every Finder window whose current view is column view) as list
set daStop to 1
repeat until daStop = ((count of items in daWindows) + 1)
set reopenMe to item daStop of daWindows
set helloPath to (target of reopenMe)
set daPosition to position of reopenMe
close reopenMe
set newWindow to (make new Finder window at helloPath)
set position of newWindow to daPosition
set daStop to (daStop + 1)
end repeat
else if (count of windows) is equal to 0 then
set fix to (make new Finder window)
close fix
end if
end tell
end run

This works _almost_ as it should. (And it's probably more complex than it needs
to be.) Where it fails is best described in this manner:

You leave a columned window open to "/Applications/Utilities", and cycle through
a log out/log in to see the script run. Well, it'll deal with the window without
closing the non-columned windows, but when the dealt-with window is recreated,
it doesn't point to "/Applications/Utilities".

Here's where I'm stumped. I can't figure out why the code I wrote doesn't work,
and I'm starting to think it's a bug in either the Finder or AppleScript (or
both). Shouldn't "make new Finder window at helloPath" work after setting
helloPath to "target of reopenMe"?

What, if anything, am I missing?

Any help is appreciated.


-/-
Michael Watson
mike@milesmedia.net
http://www.mikey-san.net/


One mans trash is another mans treasure


Filed under: Finder

Offline

 

#2 2002-02-24 02:23:37 am

Eelco Houwink
Member
Registered: 2002-11-20
Posts: 317

Re: A cry for help/Possible OS X Finder or AS bug?

I am not using OSX, but I can imagine that you have to refer to the variable "helloPath" in a different way.
I am not sure what OSX specifies as the "target" of that - but it could be something different than a true location spec.
In OS9, I tried your script to find that reopenMe returns a window specification (container window of folder "yyyy" of folder "xxxx" of startup disk of application "Finder"). Here, "open folder" would correctly read folders properties from disk - in OSX I am not aware of what "make new Finder window at" EXACTLY does.
Note. OS 9.2.2. is ever more pecky on these kind of things - in my case a reference that is not exactly "official" leads to crashing the Finder.
Hope this helps,
Eelco Houwink


Eelco Houwink

Offline

 

#3 2002-02-24 03:39:02 am

Eelco Houwink
Member
Registered: 2002-11-20
Posts: 317

Re: A cry for help/Possible OS X Finder or AS bug?

I forgot to mention an earlier posting I did some time ago about a similar failure to set OS9 Finder column widths via scripting. It might be that Apple has transferred this to OS X Finder.

Applescript:

tell application "Finder"
   activate
   set ViewTest to get (container window 1) -- b.v
   set theFolder to folder of ViewTest
   set VT to extended info for theFolder
   set fvc to finder view columns of VT
   try
       set OldVal to size of name of finder view columns of (extended info for (folder of container window 1))
   on error
       display dialog "Front window must be in list view !!" buttons {"OK"} default button 1 with icon 0
       return
   end try
   set size of name of fvc to 200
   apply --catalog info {finder view columns:fvc} to theFolder
   close theFolder
   open theFolder
   set NewVal to size of name of finder view columns of (extended info for (folder of container window 1))
   display dialog "Old column size " & (OldVal as string) & ", " & return & "Should now be 200 but is: " & NewVal as string buttons {"OK"} default button 1 with icon 1
end tell

--> new value never comes through...
Eelco Houwink


Eelco Houwink


Filed under: Finder

Offline

 

#4 2002-02-24 04:05:18 am

Trash Man
Sanitation Department
Registered: 2005-10-20
Posts: 5336

Re: A cry for help/Possible OS X Finder or AS bug?

Well, "make new Finder window" is the AppleScript command for the "New Finder Window" command in OS X's Finder. (It creates a new window at the "computer" level.)

The "target" attribute is where the window is pointing; the file or folder to which the container window leads. Making it "make new Finder window at helloPath", after setting the helloPath variable, _should_ create a new Finder window that points to/ends at helloPath. It doesn't, though--but the event log tells me this:

Applescript:

make new Finder window at folder "Utilities" of folder "Applications" of startup disk

It seems like everything should be cool, but I don't have a window whose target is "Applications Utilities"--just a new window that begins at the so-called "computer" level I'm starting to think the problem is outside/above the script, sitting in the Finder.


-/-
Michael Watson
mike@milesmedia.net


One mans trash is another mans treasure

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)