Copying file to clipboard from archive

Hey, guys.

I've tried to copy a file from archive (.rar to be precise) to clipboard. Unfortunately, this does not work, so I need to unpack archive first and then press Ctrl-C. Is there any way to make this thing easier?
I was even thinking to open archive by external utilities through standard Windows file association. But I couldn't find a way of opening file through standard file association either (right-clicking and choosing "Open with" doesn't count).

I will really appreciate it if you have some advice.

It should work, unless something is blocking/modifying the clipboard.

Are we both doing the same thing, or is there another detail involved compared to what I'm doing in the video below?

I tried to investigate this issue a little bit and here is what I've found.

  1. The behavior of copying file inside archive to clipboard and copying regular file to clipboard is different.
  2. If I copy archived file to clipboard in Opus and then paste it in Opus, it seems no different from unarchived files behavior.
  3. If I copy archived file to clipboard in Opus and then paste it in regular Explorer or, for instance, Word or Outlook, I am seeing small dialog window of Opus plugin responsible for unarchiving and then the file is being pasted.
  4. If I copy archived file to clipboard in Opus and then try to paste it in Telegram Messenger app, nothing happens. Though this paste works while copying unarchived files.
  5. I have installed Ditto clipboard manager. When I copy archived file to clipboard, it doesn't show up in clipboard history in Ditto! While regular file being copied to clipboard shows up OK in history.

When a file is inside an archive Opus presents it to the clipboard as a data stream. The program you paste it into has to support reading from data streams (as opposed to reading from normal files). Explorer does support it, but as you've found not everything does.

Thus my question stays open. Is there a way to assign shortcut to open archives by program which is associated with an extension? For example WinRAR copies archived files like a regular files. So, when I need to copy archived file to clipboard I may use WinRAR while using built-in Opus functions in all other cases.

Toolbar buttons and hotkeys which use {filepath} or similar to get the selected file, will extract the file to a temp directory before sending it to the command.


"C:\Windows\Notepad.exe" {filepath}

That will extract the selected file to a temp directory, then run Notepad.exe on the file. (Note that any edits done to it are only done to the temp copy, which is thrown away.)

You can use that to pass files inside of archives to other programs without having to manually extract them yourself.

There isn't a built-in way to do the same with the clipboard, as we use streams to put archive files into the clipboard, and it's up to other software to support that at the other end. It's far more efficient, the same thing that Explorer does (within Zip files), also used by other parts of Windows itself such as Remote Desktop, and has been part of standard Windows clipboard API for a very long time, but not everything bothers to support it.

That said, you could probably have a script which extracts the selected file, then copies its location to the clipboard. How to clean it up afterwards would be the main problem. There is no way for the program putting the file into the clipboard to know when the other program that takes it off the clipboard has finished using it. That is one of the advantages of the stream method. I guess you could have the script also check for old files and delete ones that had been sitting around for a while, on the assumption that if the file was put in the clipboard more than an hour ago (or whatever time makes sense) then it is no longer needed.

But you could also ask Telegram Messenger app to support file streams in the clipboard, as it's something applications should support and something that will make them work better with all the other things which take advantage of them, including Explorer and other parts of the OS.

leo, actually my task is a lot easier. I want to open archives by built-in archive plugin using Enter key. And I want to open archives by external utility (like WinRAR) using Ctrl-Enter for example. So, when I press Ctrl-Enter I want to get usual Explorer behavior - running utility which is associated with this extension.