sandyvs 发表于 2025-2-15 14:08:57

复制文件到剪切板


[*];[功能] 工具-复制文件到剪切板,(czx:copytoclipboard filename)
[*];[用法](czx:copytoclipboard (findfile "acad.exe"))
[*];[说明]filename = 文件完整路径
[*](defun czx:copytoclipboard (filename / dir file folder fullpath name result shell)
[*](vl-load-com)
[*](if (setq fullpath (findfile filename))
[*]    (progn
[*]      (setq dir (vl-filename-directory fullpath))
[*]      (setq name (strcat (vl-filename-base fullpath) (vl-filename-extension fullpath)))
[*]      (setq shell (vl-catch-all-apply 'vlax-create-object (list "Shell.Application")))
[*]      (if (vl-catch-all-error-p shell)
[*]      (princ "\n错误: 无法创建 Shell.Application 对象!")
[*]      (progn
[*]          (setq folder (vlax-invokeshell 'Namespace dir))
[*]          (setq file (vlax-invoke folder 'ParseName name))
[*]          (setq result (vlax-invoke file 'InvokeVerb "Copy"))
[*]          (if file (vlax-release-object file))
[*]      )
[*]      )
[*]      (if folder (vlax-release-object folder))
[*]      (if shell (vlax-release-object shell))
[*]    )
[*]    (princ "\n错误: 文件不存在或路径无效!")
[*])
[*](princ)
[*])

尘缘一生 发表于 2025-2-15 22:27:14

不错啊,剪切板再能开发出任意实体复制进去的话,就完美了。目前文字实体行。

hubeiwdlue 发表于 2025-2-15 23:02:30

谢谢分享。

crtrccrt 发表于 2025-2-17 10:02:51

一次复制多个文件,怎么办?;

sandyvs 发表于 2025-2-17 20:50:03

crtrccrt 发表于 2025-2-17 10:02
一次复制多个文件,怎么办?;

不会。。。不知道复制多个要干什么
页: [1]
查看完整版本: 复制文件到剪切板