Drag-and-Drop with Desktop Files
hh
hh at hyperhh.de
Wed Mar 13 19:44:05 EDT 2019
** Get selected files of the file manager (without user interaction like dragDrop) **
(I write the following such that also beginners can read it.)
+++++++++++++++++++++++
[a] Solution for MacOS (tested to work on MacOS 10.14):
(a1) Put the following in a field "myScript".
# Full path of selected items in Finder.
tell application "Finder"
set finderSelList to selection as alias list
end tell
if finderSelList ≠ {} then
repeat with i in finderSelList
set contents of i to POSIX path of (contents of i)
end repeat
set AppleScript's text item delimiters to linefeed
finderSelList as text
end if
(a2) Script a button and create a field "OUT".
on mouseUp
do fld "myScript" as applescript
put char 2 to -2 of the result into r
put r into fld "OUT"
end mouseUp
You'll get from the top-layered finder window lines with the full file names.
(a3) Credits.
https://forum.keyboardmaestro.com/t/getting-the-path-of-currently-selected-file-in-finder/1507
+++++++++++++++++++++++++
[b] Solution for Windows (tested to work on Win 7+10):
(b1) Save the following to a file "wscript1.js" in your stacks folder.
var shellWindows = new ActiveXObject("Shell.Application").Windows();
for (var i = 0; i < shellWindows.Count; i++) {
var w = shellWindows.Item(i);
WScript.StdOut.WriteLine(w.LocationName);
var sel = w.Document.SelectedItems();
for (var j = 0; j < sel.Count; j++) {
var item = sel.Item(j);
WScript.StdOut.WriteLine(item.Name);
WScript.StdOut.WriteLine(item.Path);
}
}
(b2) Script a button and create a field "OUT".
on mouseUp
put the effective filename of this stack into p
set itemdel to slash
put "wscript1.js" into last item of p
put shell("wscript "&p) into fld "OUT"
end mouseUp
You'll get for each explorer window its name and, for each selected file in that,
the short file name followed in the next line by the long file name.
(b3) Credits.
https://devblogs.microsoft.com/oldnewthing/?p=4593
+++++++++++++++++++++++++
[c] Solution for linux:
Linux nerds of the use-list, please complete here (at least for ubuntu 1604) ...
More information about the use-livecode
mailing list