On Dec 08, 2011, at 12:21, Robert Poland wrote: I have a script that uses the following;
tell application "Finder" delay 10 set selected_Item to selection delay 10 display dialog "" & selected_Item end tell
If I open, for example, the Applications folder and select any item then run the script "selected_Item" is empty. If I run the script again all is well.
______________________________________________________________________
Hey Bob,
Re: Is finder brain dead? Not quite, but it's buggy.
This is the Lion bug I worked around in the script I sent you a while back.
I posted a very lengthy test to the list when Lion first came out to see if the problem was local to my system only, unfortunately it turned out to be a bug. A major bug in my opinion that I'm amazed has gone unfixed to date.
This problem is intermittent. When it happens the Finder appears to lose track of which window is frontmost, and usually the list returned by selection is from the window in back of the front window.
This can cause some very unexpected results if there is a selection in that window...
The only work-around I know of is to force the Finder to refresh its window index by opening and closing a new Finder window.
tell application "Finder" set lionBugFixWin to make new Finder window close lionBugFixWin set sel to selection as alias list end tell
On my system I'm able to reliably cause the bug to appear by using Cmd-Ctrl-O to open a folder into a new window. If I do this without my fix then sel will be the folder I just opened rather than the selection in the new window.
Try this:
Open a new folder in the Finder and make a selection - then open another window and close it - then run this script:
set docs to path to documents folder tell application "Finder" open docs set _fldr to select first folder of front window open _fldr select items of front window set sel to selection as alias list end tell
The selection is not what it should be.
Not thrilling at all.
The funny thing is that this seems to only affect selection. If you move or resize the front window all goes as expected.
-- Best Regards, Chris
|