Drag-and-Drop with Desktop Files

R.H. roland.huettmann at gmail.com
Thu Mar 14 09:25:53 EDT 2019

 I am referring to:
Message: 17, Date: Thu, 14 Mar 2019 00:44:05 +0100, From: hh <hh at hyperhh.de

Regarding MacOS I can not say much, but I use Windows, and IT WORKS.

'hh ' = Hermann's contribution, right? This fantastic. I never expected
anybody to have a solution. I had searched Git and whatever.

Well, first it did not actually work because spaces in the folder- and
filenames are breaking the script. There will be an error message. So, I
have added these script lines to what 'hh' had posted:

-- Button script
on mouseUp
    set the hideConsoleWindows to true -- Hide console window
    put the effective filename of this stack into p
    set the itemdelimiter to slash
    put "wscript1.js" into last item of p -- Or construct any other valid
file path
    --replace slash with backslash in p  -- Not needed, works without
backslash conversion
    put quote & p & quote into p -- Required if file- or folder names
contain spaces, and mostly they do
    put shell ("wscript "&p) into msg -- or any field, ...
end mouseUp

Operating system: Windows 10, the latest version
OS scripting language: Wscript (Microsoft Windows Script Host File)
Filename of script file: "wscript.js"
Location: Here the call file is placed inside the stack folder (could be
any other location)
Script of the file as given by Hermann:

var shellWindows = new ActiveXObject("Shell.Application").Windows();
for (var i = 0; i < shellWindows.Count; i++) {
var w = shellWindows.Item(i);
var sel = w.Document.SelectedItems();
for (var j = 0; j < sel.Count; j++) {
var item = sel.Item(j);

Biggest THANK YOU.  You solved the client request in a very elegant way and
I create this script file "on the fly" from within LiveCode and execute it
on the client's Windows system.

Thanks for all contributions

More information about the use-livecode mailing list