On OS X Lion, asking Finder for the current selection returns an invalid file

I confirmed that this happens only in Leo. I found that it seems like an error when you need to double-focus the window so that Finder returns the correct result from a script or AppleScript. This only happens when opening a folder from the desktop or another location.

Here's how to duplicate:

  • Close, hide or minimize all windows until the desktop appears.
  • Open any folder on your desktop, a new search window will appear. Select any file in this search box by clicking it once.
  • Open the AppleScript editor and run the following script:

    tell application "Finder" return selection end tell 

The script will only return the path to the folder on the desktop, not the selected file in the search box.

If you reorient the window or click on the file again, everything will work as expected and the script will return the correct path.

This seems like a bug in Lion. Snow Leopard returns the correct path in 100% of cases.

I tried the following methods without success:

Everyone seems to have the same problem.

Am I missing something obvious or is this really a problem with Lion?

+6
source share
1 answer

Wow, I can confirm (at least through applescript) most of what you described. I get an empty list, not even the desktop you mentioned. I tested this using a script in the applescript menu. The only way to get a choice from the new Finder window was this ...

 tell application "System Events" to activate tell application "Finder" activate set a to (get selection) as text display dialog a end tell 
+1
source

Source: https://habr.com/ru/post/903407/


All Articles