I’m trying to retrieve the selection of a specific window each time I run a script, the alias of ‘get selection as alias’ command will be my content used in each script run.
I have noticed that the command
tell app "Finder"
get selection as alias
end tell
will get the selection of the window whose frontmost property is set to true.
So to get the selection of a specific window, I would set the desired Finder window to the front (which also activates Finder app), and then get the selection.
but the problem: I need to run this script while using another application, so activating the Finder everytime I run the script is undesired.
I have tried these:
This way activates the application, undesired. But allows me to get new selection contents per window each time.
tell application "Finder"
set theTitle to "67 Heavy Signal"
tell application "System Events"
tell process "Finder"
set frontmost of window 1 to true
end tell
end tell
get selection as alias
end tell
This brings the window to the front, but doesn’t allow me to get the selection of the window when I run ‘get selection as alias’.
tell application "Finder"
set index of window 1 where name contains "Desktop" to 1
delay 0.05
get selection as alias
end tell
So how can I get the contents of a specific window without activating the Finder app?
Do you know that in foreign countries the Desktop isn’t named Desktop ?
I edited your script as :
(path to library folder from system domain as text) & "CoreServices:SystemFolderLocalizations:"
set Desktop_loc to localized string "Desktop" in bundle file result from table "SystemFolderLocalizations"
tell application "Finder"
name of windows
set index of window 1 where name contains Desktop_loc to 1
delay 0.05
get selection as alias
end tell
No, there isn’t such a list.
For the folders defined by the system you may look at :
Macintosh HD:System:Library:CoreServices:SystemFolderLocalizations:
I edited my proposal so that it grabs the localized name of the Desktop from it.
Yvan KOENIG (VALLAURIS, France) jeudi 8 mai 2014 09:41:16