Re: wrong result when trying to get Selection from finder window
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