Drag&Drop File on Button

I have created a button (for starting the editor Notepad++) with the following functionality:

cd %USERPROFILE%
@keydown:!ctrl
@async:"C:\PortableApps\Notepad++\notepad++.exe"
@keydown:ctrl
@async:"C:\PortableApps\Notepad++\notepad++.exe" "{filepath}"

This works fine.

Now I would like to add the functionality of dropping one or more files on the button which I drag from the lister.

I am grateful for any assistance.

Note that "{filepath}" should be just {filepath}, as it is automatically quoted if the path contains spaces (which will result in double quotes if they're also added explicitly).

I'm not sure there is a way to make drag & drop work if you want it to only open the file when Ctrl is held down, since the button won't see the Ctrl key in that context.

I would use this instead:

@filesonly
cd %USERPROFILE%
@async:"C:\PortableApps\Notepad++\notepad++.exe" {allfilepath}

That will work with drag & drop automatically.

If any files are selected, the button will open them in Notepad++. If nothing (or a folder) is selected, it will just launch Notepad++ without passing any paths to it.

1 Like

It will. With the right glasses :wink:

@filesonly
cd %USERPROFILE%
=return "@async:C:\PortableApps\Notepad++\notepad++.exe" + (KeyDown("ctrl") ? " {allfilepath}" : "")
2 Likes

Many thanks to both of you for your efforts and the excellent answers. As I didn't find my approach with CTRL really elegant, I have discarded it in favour of Leo's solution. But lxp's solution is also interesting if CTRL is desired.

1 Like