1

I have recently encountered this very odd behavior using the basic Notepad of Windows 10, and I can't figure out what could explain it.

I'm using the MT Power Drumkit 2 plugin for the LMMS music generator program. The former has its own temporary folder, which is only used to temporarily save the drum sequence created with the plugin, as a .midi. The file is always saved as mtpdk.mid.

Learning to use the plugin, I found some resources that advised you could drag & drop the drum sequence created on the plugin's GUI into an empty Notepad, and save it as a .midi file.

Now comes the weird part, where I need help with.

When dragging and dropping this way, from the plugin GUI into a new, empty, untitled Notepad, as soon as the contents appear, the Notepad app automatically shows mtpdk.mid as the file name, and saves the contents.

I suspect what happens is that Notepad somehow recognizes the contents match the existing mtpdk.mid file, and swaps the untitled file I created to the existing one.

This baffles me greatly. It's the equivalent of opening an empty Word document, pasting "One brown fox" in it, and if there is a saved .docx file, say fox.docx with "One brown fox" in it, Word would automatically swap from your newly created empty document to this fox.docx.

  1. Is this possible, and how does Windows recognize what's going on?
  2. The plugin temp folder is in C: (as in C:/tempFolder). Is that relevant to the behavior?
  3. Are there any security considerations regarding this?
1
  • I was able to duplicate the behavior with a PDF document but the file being viewed by Notepad wasn't automatically saved. As indicated in the answer below you are just viewing the contents of the file not creating and saving the file. Word already attempts to guess at a filename.
    – Ramhound
    Jul 28 at 21:09
2

No, there's no magic content recognition here. You're actually not dragging any content into Notepad to paste it – you're dragging an actual file into Notepad to open it. So it is not automatically saving anything but opening a file that has already been saved previously.

It sounds like your program deliberately sets up its drag source to offer a "shell object" (and not just the plain MIDI data). When you drop it into Notepad, it looks at the data types provided through the "drag source", and if it sees that it's being offered a file, it opens that file.

(In fact, I don't think Notepad even accepts text being dragged into it? Other editors commonly allow that, but the standard Windows Notepad actually does not.)

This means that you should also be able to drag the same sequence directly to a folder and I expect that Explorer would recognize this as a file copy.


You can also try dropping it into WordPad or Microsoft Word. If you drop something onto WordPad's title bar/button bar it'll be opened as a file; but if you drop it into the "document" area it'll get inserted either as text or as an OLE object, so you can see exactly what you were dragging.

1
  • 1
    The behavior described in this answer can be duplicated with a Word or PDF document. Notepad does not support highlighting text within a browser and dragging it into Notepad.
    – Ramhound
    Jul 28 at 21:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.