How does files get copy/cut/paste using clipboard operations (ctrl-c /ctrl-v)

天大地大妈咪最大 提交于 2019-12-08 01:24:37

问题


Was trying to use win32clipboard to do the copy paste operations for text (till now), and was able to do it with ease.But now am wondering how does the copy/paste operations would be accomplished for folders/files etc through that. I am using python to achieve the same. Could not also find any relevant formats for that. Is it something like file path gets copied and then paste operation identifies clipboard data as file path and then actually does the file copy? No clue :(.


回答1:


Windows copy/paste stores things as OLE objects (http://en.wikipedia.org/wiki/Object_Linking_and_Embedding) You need a python package to deal with OLE. This thread might help- How do I script an OLE component using Python?




回答2:


When you copy a shell object (e.g. a file or a folder) to the clipboard, the shell places data into the clipboard in a variety of different formats. The clipboard viewer for such an operation shows the following formats:

I honestly don't know which one is used when you subsequently paste, but my guess would be the Shell IDList Array. The point is that the files and folders don't go into the clipboard, only references to them.

I believe that there is comprehensive documentation of this on MSDN: Shell Clipboard Formats.

That should give you enough orientation to conduct a further web search for Python wrappers to such functionality (I'm sure they will exist)!



来源:https://stackoverflow.com/questions/5016874/how-does-files-get-copy-cut-paste-using-clipboard-operations-ctrl-c-ctrl-v

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!