• 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: Axel Luttgens <email@hidden>
  • Date: Fri, 02 Nov 2012 10:59:52 +0100

Le 2 nov. 2012 à 10:27, Ronald Hofmann a écrit :

> I have the following in Mountain Lion and this only happens when opening a folder from the desktop or another space.
>
> Here's how to duplicate:
> 	• Close all finder windows.
> 	• Open any folder on the desktop, a new finder window will appear. Select any file in that finder window by clicking on it once.
> 	• Open your AppleScript Editor and run the following script:
>
> tell application "Finder"
> 	return selection
> end tell
>
> The script will return only the path to the folder on the desktop, not the selected files in the finder window.
>
> Any clues how to get the correct result?
>
> [...]

Hello Ronald,

I've just tried the steps you've described above, and got the same (negative) result here on 10.8.2.
IIRC, such problems already occurred with earlier versions of the OS...

Anyway, it seems that the Finder needs some trigger to correctly update its selection property. Quick trials tend to show that an activate command may help, as in:

	tell application "Finder"
		activate
		selection
	end tell

Should the former be too disruptive, by bringing the Finder to the front:

	tell application "System Events" to set currApp to item 1 of (processes whose frontmost is true)
	tell application "Finder" to activate
	tell application "System Events" to set frontmost of currApp to true
	tell application "Finder"
		selection
	end tell

HTH,
Axel


 _______________________________________________
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>)

  • Prev by Date: Re: wrong result when trying to get Selection from finder window
  • Next by Date: Re: Saving to array list
  • 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