Copy File Contents
Copies a selected file's text or its SHA-256 hash without opening it in an app, from a keyboard shortcut or the right-click menu.
Author: metanoid18
Adds two actions to File Explorer, so a file can be read without opening it in an app:
- Copy contents puts the text of the selected file on the clipboard.
- Copy SHA-256 puts the hash of the selected file on the clipboard.
Several files can be selected at once. Contents are copied one after another with
the file name above each, and hashes are copied one per line. A setting can put
each file on the clipboard as its own item instead, which keeps them apart in
Windows clipboard history, so Win+V offers each file on its own.
Two ways to reach it
Keyboard. Select files, then press Ctrl+Shift+T for the contents or
Ctrl+Shift+H for the hash. This works with the new Windows 11 menu, because it
does not go through the menu at all. The shortcut is only live while a File
Explorer window has the focus and the file view is the one being pointed at, and
it is ignored while the rename box, the address bar or the search box has the
focus, so it never eats a letter you are typing. Every key combination here can
be changed in the settings. Do not reuse Ctrl+Shift+C or Ctrl+Shift+N, which are
File Explorer's own Copy as path and New folder, because the mod would take the
key from Explorer.

Right-click. The two entries are also added to the classic menu, reached
with Show more options or Shift+F10. They are added at the bottom of that
menu, below Properties, and removed again once the menu closes, so the menu is
never left modified. The mod does not add entries to the new Windows 11 menu.
To get the entries on a plain right-click, use
the separate mod Classic context menu on Windows 11. If the classic menu
cannot be reached on your build, the keyboard shortcuts are the whole of the mod
and they do not need the menu at all.
What it will and will not copy
A file is copied only if it looks like text. Files that look binary are refused
rather than pasted as garbage, and files larger than the size limit are refused
the same way. When no file contents can be read, an optional prompt shows the
reason. A clipboard write failure with no successful item is reported separately.
For an oversized local
file up to 32 MB whose prefix looks like text, the optional prompt offers
to open it in Notepad instead. This prefix check is only a heuristic. Network and
offline files are not opened for the offer. The path is passed quoted so a path
with a space in it still opens.
The size limit is 8 MB by default, with the unit chosen next to it, megabytes or
kilobytes. A large selection is copied file by file, so one file over the limit is
skipped and the rest are still copied. That partial copy is silent, because a
dialog in the middle of copying five files is worse than a missing one. In joined
mode, a multi-file selection identifies each result even if only one file succeeds.
When nothing at all can be read, the optional prompt explains why instead.
The decoded text in one selection is held to a 32 MB budget. A file bigger on
disk than what is left of that budget is skipped without being opened, even if
its decoded text might have fit. Once the remaining budget is very small, the rest of the
selection is not read at all. Smaller files are read and their decoded text is
measured: depending on the encoding it may be smaller or larger than the bytes on
disk. File names and temporary buffers are outside the budget, so total memory use
can be higher.
The ceilings are 64 MB per file and 32 MB per selection whatever the settings
say. In practice the per selection budget is the one that binds: no single file is
copied beyond 32 MB of text, which is the same as saying that a 20 MB UTF-16 file
is copied and a 20 MB ASCII file is not. A text file that big is already beyond
what a clipboard is good for, and the mod refuses rather than trying.
When the selection appears uncopyable, Copy contents is usually left out of
the menu instead of being offered and then refusing. To decide that, the first 4 KiB
of each file are read when the menu opens, stopping at the first file that
passes, and looking at no more than 16 files. Files that are offline or stored
online only are not read at all, because reading one would start a download; such
a file is assumed copyable and the copy itself decides. Files on a network share
are treated the same way, whether they are reached by a \\server\share path or
through a drive letter mapped to one, because reading from a share that has
stopped answering would hang the menu. A mixed selection still shows the entry
and copies the files that can be copied.
Encoding is detected rather than assumed: a byte order mark is honored, then the
file is checked for UTF-16 without a mark, then for strict UTF-8, and finally read
as the system code page. UTF-16 is checked before UTF-8 on purpose: the zero bytes
of a UTF-16 file are valid UTF-8, so the other order would decode such a file as
text with invisible gaps. Line endings are copied as they are.
Large hashes
Hashing reads every byte, and the work runs on the same thread that owns the File
Explorer window, so that window does not repaint until it is done. Large files
and slow drives or shares can take a long time. Above the size set in the
settings, 256 MB by default, the mod asks first, and says how many
files and how much data are involved, using the sizes it could read across the
selection rather than one file at a time. Answer no and nothing happens. The
setting can be raised to where hashing a whole disk in one go is on you, or set
to 0 to be asked every time.
If no selected file can be hashed, a message warns that no hash was copied and
the clipboard may contain earlier data. If some files fail, successful hashes
are copied without a dialog, with file names when more than one file (not a folder)
was selected.
Known limits
- Only files. A selection of folders, or the desktop, does nothing.
- The shortcuts act in File Explorer windows only. They do nothing in other
programs and nothing on the desktop.
- The contents are put on the clipboard as text. Nothing is written to disk, and
no temporary file is created.
- When the mod is turned off, it asks open menus and its prompts to close and
waits for tracked hook calls to finish. A menu or prompt that does not close
may need to be closed manually. The mod attempts to cancel its pending file
operations when unloading, but cancellation is not guaranteed. A stalled
operation may still leave Windhawk uninitializing indefinitely; the Explorer
window can remain unresponsive. Cancellation targets a thread, so unrelated
I/O reentered on that thread during a mod file call could also be canceled.
A dialog opened by another Explorer shortcut, or another mod's hook, may also
delay uninitialization until it closes or returns. Other mod
updates in the process may have to wait. The delay between separate clipboard
items ends early when unloading starts.
- With separate clipboard items turned on, Ctrl+V pastes only the last file. The
earlier ones are reachable through Windows clipboard history (Win+V), and only
there, and clipboard history has to be turned on for them to be kept.
- Clipboard history keeps 25 entries and about 4 MB per entry, which for text is
roughly two million characters. A file bigger than that cannot be a history
entry however it is copied; Windows drops it and tells no one. So in separate
items mode those files are written last: the history keeps the files it can
hold, and Ctrl+V gives the big one.
- Windows clipboard history is a separate service and it needs a moment between
copies, so the files are written with a short wait, 250 ms by default and
adjustable. The wait runs on File Explorer's thread, so a large selection takes
that much longer to finish copying, and the window is briefly unresponsive
while it does.
- A file being written by another program while it is read may be copied partially.
That is a race no reader can win, and it is not worth a lock for this.