Drag-and-Drop with Desktop Files

R.H. roland.huettmann at gmail.com
Thu Mar 14 10:02:40 EDT 2019


hh, I have one more question for Windows: Selecting a file through
Microsoft File Explorer on Windows 10 works for all selected files with
your wscript, also when it is a Desktop file accessed through the dialogue.

The problem I have is when the user selects a file _directly_ visible on
the Desktop, wscript will not catch the file. Is there a way to find such
selected files on the Desktop when users just selected files there? I am
not familiar yet with wscript.

And I can not catch this attribute using the
files(specialfolderpath("desktop","detailed")) function in LiveCode.

Thanks, Roland


> 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
>
> Tested:
> 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);
> 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);
> }
> }
>
> 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
> Roland
>



More information about the use-livecode mailing list