• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: wrong result when trying to get Selection from finder window
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: wrong result when trying to get Selection from finder window


  • Subject: Re: wrong result when trying to get Selection from finder window
  • From: Christopher Stone <email@hidden>
  • Date: Fri, 02 Nov 2012 17:28:10 -0500

On Nov 02, 2012, at 09:42, Ronald Hofmann <email@hidden> wrote:
that sounds strange. Here it seemed to me that the problem did not occur before yesterday. At least I was not aware of it.

Any idea what could cause the problem?
______________________________________________________________________

Hey Ronald,

Yep.  It's a bug in the OS.

I discovered it shortly after Lion came out and a number of people have duplicated my results.

The specific sequence you used to create the failure may or may not be reliably repeatable on Lion, but the bug exists nevertheless.

If you switch application-contexts to run the script the bug may not present.

Running this script from FastScripts in the Finder using your stated methodology reproduces the bug with absolute reliability on my 10.8.2 system.

-------------------------------------------------------------------------------------------
tell application "Finder"
set sel to selection as alias list
repeat with i in sel
set contents of i to name of (contents of i)
end repeat
end tell
choose from list sel with title "Finder-Selection-Bug-Test" with empty selection allowed
-------------------------------------------------------------------------------------------

I discovered the bug originally in Lion, because I have 20+ scripts that operate on the Finder-selection in some way.  I had odd intermittent failures where something that had worked for years failed.

I first noticed a pattern when using LaunchBar to reveal an application in the Finder, and then running a script utilizing the Finder-selection (which sometimes failed to work properly).  Shortly thereafter I noticed that if there was a selection in the window behind the newly opened (front) window with a new selection that the items in the window behind the front window were the ones acted upon.

My original test script still exposes the bug with complete reliability:

-------------------------------------------------------------------------------------------

try

  

  set homeFlAlias to path to home folder
  set docFlAlias to path to documents folder
  set downArrow to (ASCII character 31)

  

  tell application "Finder"
    close every window
    activate
    delay 0.2
    open homeFlAlias
    select items 1 thru 3 of front window
    set bounds of front window to {0, 44, 870, 520}
    open docFlAlias
    set bounds of front window to {550, 44, 1420, 520}
    close front window
  end tell

  

  do shell script "open ~/Documents/"
  delay 0.3

  

  tell application "System Events"
    tell process "Finder"
      keystroke downArrow
      keystroke downArrow using {shift down}
      keystroke downArrow using {shift down}
    end tell
  end tell

  

  tell application "Finder"
    delay 2
    set sel to selection as alias list
    if sel ≠ {} then
      repeat with i in sel
        set label index of i to 2
      end repeat
      update target of front window
    end if
  end tell

  

on error e number n
  set e to e & return & return & "Num: " & n
  tell me to set dDlg to display dialog e with title "ERROR!" buttons {"Cancel", "Copy", "OK"} default button "OK"
  if button returned of dDlg = "Copy" then set the clipboard to e
end try

-------------------------------------------------------------------------------------------

It was posted to the list roughly 30 days after Lion was released:

   From: Christopher Stone <email@hidden>
   Date: Thu, 25 Aug 2011 15:23:18 -0500
Subject: Finder Selection Bug in Lion

http://lists.apple.com/archives/applescript-users/2011/Aug/msg00340.html

--
Best Regards,
Chris

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >wrong result when trying to get Selection from finder window (From: Ronald Hofmann <email@hidden>)
 >Re: wrong result when trying to get Selection from finder window (From: Christopher Stone <email@hidden>)
 >Re: wrong result when trying to get Selection from finder window (From: Michelle Steiner <email@hidden>)
 >Re: wrong result when trying to get Selection from finder window (From: Ronald Hofmann <email@hidden>)

  • Prev by Date: Re: wrong result when trying to get Selection from finder window
  • Next by Date: Re: Checking on the existence of a file
  • Previous by thread: Re: wrong result when trying to get Selection from finder window
  • Next by thread: Re: wrong result when trying to get Selection from finder window
  • Index(es):
    • Date
    • Thread