Drag-and-Drop with Desktop files

2019-03-18 Thread R.H. via use-livecode
Sub-Subject: Detecting user selected files/folders in Windows and other
OSes.

I like to refer to the last message from -hh (see reference below)
regarding Windows possibility of detecting selected items (folders, files,
icons as such) on the Windows Desktop. The solution -hh already provided
when items are selected in any Windows Explorer. The Desktop is not part of
that and basically a special Windows ListView control.

It is correct that items selected on the Windows Desktop are deselected
when another window is becoming active. So, using LiveCode would not work
this way.

What could work though is a service that is running in Windows OS and
detects selected items of the Windows Desktop and their status of type,
selection and position, etc. The service could be started when opening
LiveCode and shut down when closing it. Data would be saved to a temporary
file.

So, switching focus to the LiveCode window would allow reading the temp
file with the list of selected items that have been selected BEFORE the
user activated the LiveCode window.

It is too much of a hassle at the moment for me writing such a program that
runs in the background. Nevertheless, for C/C++ and C# there are some code
fragments around that are public and doing just that.

For my clients, it is a very good solution to be enabled now to select
files/folders and read their path into LiveCode. For Desktop items in
Windows, I just tell them to move them into a folder and select them within
this folder (which is then an Explorer window). So, that works with scripts
-hh provided.

THIS IS MORE CONVENIENT THAN DRAG-AND-DROP of files/folders even though I
also support drag-and-drop plus the standard file/folders selection window.

Many thanks again. And I hope the same will work on MacOS and Linux as -hh
also provided solutions there, and I saw others providing. (I am not using
both others OSes since my clients are 100% Windows only.)

--Message: 16
--Date: Thu, 14 Mar 2019 21:33:32 +0100
--From: hh 

--But there is NO method to get the selectedItems from the virtual desktop
folder.
--Moreover, as you may notice, the selected items are deelected when you
activate
--another window (as for example a LC window or an explorer window).
--The only workaround I can see (besides using an answer file dialog or
dragDrop) is:

--1. launch document specialFolderPath("Desktop") --> open desktop folder
in explorer
--2. User should select the files in that window.
--3. Use the already working method for explorer windows.

Kind regards and thanks to all
Roland
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Drag-and-Drop with Desktop Files

2019-03-15 Thread Bob Sneidar via use-livecode
I'll toss together an Applescript for you when I get a chance. 

Bob S


> On Mar 14, 2019, at 06:25 , R.H. via use-livecode 
>  wrote:
> 
> I am referring to:
> Message: 17, Date: Thu, 14 Mar 2019 00:44:05 +0100, From: hh > 
> 
> 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:

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Drag-and-Drop with Desktop Files

2019-03-14 Thread kee nethery via use-livecode
I had drag and drop in my macOS app but … when going with the AppStore, and 
sandboxing, there was no way for drag and drop to trigger the sandbox 
permission that would allow the app to read that file. I knew which file, but 
since it did not go through the dialog box, the permission wasn’t set.

So I took drag and drop out of my app and it passed store app review.

Kee

> On Mar 13, 2019, at 4:44 PM, hh via use-livecode 
>  wrote:
> 
> ** 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 ") 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) 
> ...
> 
> 
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Re: Drag-and-Drop with Desktop Files

2019-03-14 Thread hh via use-livecode
Hi,

I use MacOS or linux (on Raspi only), never really worked with windows.
I'm using Windows only to test my stacks/apps on the PC of my youngest son.

Scripting Host-WScript can execute JScript, the MS-extension of ECMAScript. It 
has a
lot of features. We probably can use a lot of these features via LC's shell.

I looked into that out of interest the first time last week. It is well 
documented:
https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/wscript
And it seems to be better maintained than VBScript.

But there is NO method to get the selectedItems from the virtual desktop folder.

Moreover, as you may notice, the selected items are deelected when you activate
another window (as for example a LC window or an explorer window).

The only workaround I can see (besides using an answer file dialog or dragDrop) 
is:

1. launch document specialFolderPath("Desktop") --> open desktop folder in 
explorer
2. User should select the files in that window.
3. Use the already working method for explorer windows.


file "wscript1.js" (more compact output)

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);
WScript.StdOut.WriteLine(item.Path);
}
}


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Drag-and-Drop with Desktop Files

2019-03-14 Thread R.H. via use-livecode
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 <
> h...@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 ") 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
>
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Drag-and-Drop with Desktop Files

2019-03-14 Thread R.H. via use-livecode
 I am referring to:
Message: 17, Date: Thu, 14 Mar 2019 00:44:05 +0100, From: hh 

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 ") 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
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Drag-and-Drop with Desktop Files

2019-03-13 Thread hh via use-livecode
** 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 ") 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) ...


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Drag-and-Drop with Desktop Files

2019-03-13 Thread R.H. via use-livecode
Jacqueline:
   on dragDrop -- check for file paths
  get the dragData["files"]...
   pass dragDrop end dragDrop

Jacqueline, thank you. I know this and wrote about it.

Here I want to know the filename and path which is
user-selected in the OS (on Windows File Explorer) without dragging
and dropping
it to the LiveCode window.

I am looking for a Powershell function that can be
invoked in LiveCode. I failed to do this so far even though trying.

How do we call Powershell in LiveCode? I can do it with Shell functions and
with outdated VBScript.

If I get it working myself, I will post it.

Thanks, Roland
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Drag-and-Drop with Desktop Files

2019-03-12 Thread Bob Sneidar via use-livecode
I think he was trying to get the OS to tell him which files were hilited by the 
user without having to drag and drop. At least that is what I got from the 
post. 

Bob S


> On Mar 12, 2019, at 11:17 , J. Landman Gay via use-livecode 
>  wrote:
> 
> See the entry for dragDrop in the dictionary. You can get the file paths from 
> there.
> 
> on dragDrop -- check for file paths
>  get the dragData["files"]
>  ...
>  pass dragDrop
> end dragDrop


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Drag-and-Drop with Desktop Files

2019-03-12 Thread J. Landman Gay via use-livecode
See the entry for dragDrop in the dictionary. You can get the file paths 
from there.


on dragDrop -- check for file paths
  get the dragData["files"]
  ...
  pass dragDrop
end dragDrop

On 3/12/19 10:46 AM, Bob Sneidar via use-livecode wrote:

On a Mac you could just make an Applescript call to the Finder. Windows, I 
don't know. There is probably a powershell call that will do it.

Bob S



On Mar 8, 2019, at 06:46 , R.H. via use-livecode 
 wrote:

Desktop and IDE, mainly Windows 10 (could be any OS), LiveCode lastest
version.

Drag-and-Drop on Windows works as expected. But I have another request and
do not know how to handle it so far.

The OS should know which file a user has selected. Is there are a command
or Shell function to know which files are selected in the Operating System
to receive their file path back in LiveCode without much user interaction.
The user shall NOT move the file as in Drag-and-Drop, but just click a
button to know about these selected files and folders and process them as
desired.

Speaking about Windows, only folders and files in a current folder can be
user-selected. So, if we had the information about the currently selected
folder and the selected files and folders inside, it would be a huge
advantage for the application I am working on.

Thanks for any hint if this is conceivable.



___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode




--
Jacqueline Landman Gay | jac...@hyperactivesw.com
HyperActive Software   | http://www.hyperactivesw.com

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Drag-and-Drop with Desktop Files

2019-03-12 Thread Bob Sneidar via use-livecode
On a Mac you could just make an Applescript call to the Finder. Windows, I 
don't know. There is probably a powershell call that will do it. 

Bob S


> On Mar 8, 2019, at 06:46 , R.H. via use-livecode 
>  wrote:
> 
> Desktop and IDE, mainly Windows 10 (could be any OS), LiveCode lastest
> version.
> 
> Drag-and-Drop on Windows works as expected. But I have another request and
> do not know how to handle it so far.
> 
> The OS should know which file a user has selected. Is there are a command
> or Shell function to know which files are selected in the Operating System
> to receive their file path back in LiveCode without much user interaction.
> The user shall NOT move the file as in Drag-and-Drop, but just click a
> button to know about these selected files and folders and process them as
> desired.
> 
> Speaking about Windows, only folders and files in a current folder can be
> user-selected. So, if we had the information about the currently selected
> folder and the selected files and folders inside, it would be a huge
> advantage for the application I am working on.
> 
> Thanks for any hint if this is conceivable.


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Drag-and-Drop with Desktop Files

2019-03-08 Thread R.H. via use-livecode
Desktop and IDE, mainly Windows 10 (could be any OS), LiveCode lastest
version.

Drag-and-Drop on Windows works as expected. But I have another request and
do not know how to handle it so far.

The OS should know which file a user has selected. Is there are a command
or Shell function to know which files are selected in the Operating System
to receive their file path back in LiveCode without much user interaction.
The user shall NOT move the file as in Drag-and-Drop, but just click a
button to know about these selected files and folders and process them as
desired.

Speaking about Windows, only folders and files in a current folder can be
user-selected. So, if we had the information about the currently selected
folder and the selected files and folders inside, it would be a huge
advantage for the application I am working on.

Thanks for any hint if this is conceivable.

P.S. Windows users: Does anybody of you has a beginners script of using
Powershell instead of VBScript on Windows? As far as I know, VBScript is
deprecated. How would we call Powershell and receive information in LC back
from Powershell? Powershell does not appear in the list of supported
scripting languages of the OS when calling "alternateLanguages".
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode