Obtain list of file(s) currently copied to clipboard

Files can be copied via right click in windows file explorer. How can I obtain a list of file(s) and resolve to a FolderItem after the user has copied them to the clipboard?

I am seeing in documents text is easy to obtain, so are pictures, but I am not seeing anything on files. RawData may work, but I need to know the data type prior to reading.

Ultimately I want users to be able to use file explorer to copy files, then paste the link to file in my app.

Ideas?

I’d suggest you experiment with the various object types the Xojo framework knows how to access. Perhaps the file paths are passed as text, for example.

If you use MBS Xojo Plugins, please check WindowsClipboardMBS function and the GetFiles function.

1 Like

at windows 11 you have to hold shift and use the menu copy as path.

otherwise windows copy file pointers …

that could be not feasible because you have to see the files and a window as drop target.
files could be dropped before the target unwanted and windows messed up.

This case never comes to me.

But, as I stated in my prior message, the mechanicsa to get the files contents is the same, so it’s OP UI.

Mac users have the tendency to drag and drop
Windows users have the tendency to right-clic…

I think I was wrong (far above)…

In the Exlorer, you Right-Click one or many items,
In the Xojo window, you place a ConstructContextualMenu Event and deal there with the File(s) yu already have “copied”…

Function ConstructContextualMenu(base As DesktopMenuItem, x As Integer, y As Integer) Handles ConstructContextualMenu as Boolean
  ' Add some items
  base.AddMenu(New DesktopMenuItem("Paste Item(s)"))
  
  Return True
  
End Function


Function ContextualMenuItemSelected(selectedItem As DesktopMenuItem) Handles ContextualMenuItemSelected as Boolean
  Var Clip As New Clipboard
  
  If SelectedItem <> Nil Then
    
    If selectedItem.Text = "Paste Item(s)" Then 
      
      Beep
    End If
  End If
  
  Clip.Close
  
  Return True
End Function

Clip contents:
image

rough, but you get the idea. (done with a mac).
I selected:

a rar file, a folder and a jpg file (by pure hazard, the idea was to choose different ob,ects).

This is true, not only that, they can select multiple files while holding the shift or control key while selecting and then right clip to copy all. That’s why I want mechanism to use existing methods the users are used too.

Emile,

I am looking for a Windows solution, hence the Windows category in the OP. But thanks.

i have a other idea which is maybe possible.
register a send to app for the explorer context menu.
similar compress to zip menu in windows explorer.
at least it not need a shift key hold for the extra context menu.
or this open with app menu.

That’s interesting Markus. Any idea how to do that?

just add a shortcut file to the right folder.

See

Your app installer can do this.

2 Likes