将 HTM 文件的内容复制到剪贴板
Copy content of HTM file into clipboard
我的机器上本地保存了一个文本 htm 文件,我想使用 AutoHotKey
脚本将其内容复制到剪贴板。我试过了:
FileRead, Clipboard, *c C:\Users\%A_UserName%\AppData\Local\Temp\file.htm
和
UrlDownloadToFile, C:\Users\%A_UserName%\AppData\Local\Temp\file.htm, NewTextFile.txt
但他们都没有奏效。
我能想到的唯一解决方法是在浏览器中使用以下命令打开 htm 文件:
Run, C:\Users\%A_UserName%\AppData\Local\Temp\file.htm
and Ctrl+A and next Ctrl+C 但这并不理想。
你确定路径是正确的吗?如果你这样做:
FileRead, Clipboard, C:\Users\%A_UserName%\AppData\Local\Temp\file.htm
MsgBox %ErrorLevel%
MsgBox 说什么? "ErrorLevel is set to 0 if the load was successful. It is set to 1 if a problem occurred such as: 1) file does not exist; 2) file is locked or inaccessible; 3) the system lacks sufficient memory to load the file." 来源:https://autohotkey.com/docs/commands/FileRead.htm
您安装的是哪个版本的 AutoHotkey?如果您有一个非常旧的版本,它可能难以读取 Unicode (utf-8) 文件(不确定)。
如果可能,请务必下载并安装最新版本 https://autohotkey.com/download/
FileRead 应该可以正常工作。但是它会将HTML代码的内容读取到剪贴板。如果您想要 HTML 文件的格式化文本,例如段落、粗体、斜体、列表、表格等。您需要使用 WinClip() 库的不同技术。
- 从这里下载并解压 WinClip() 库 https://autohotkey.com/board/topic/74670-class-winclip-direct-clipboard-manipulations/
创建一个新脚本,这将读取 HTML 文件并将格式化文本读入内存并粘贴(例如在 Office 或其他接受格式化输入的程序中执行此操作) :
#Include WinClipAPI.ahk
#Include WinClip.ahk
wc := new WinClip
WinClip.Clear()
FileRead, html, C:\Users\%A_UserName%\AppData\Local\Temp\file.htm
WinClip.SetHTML(html)
WinClip.Paste()
来源:How to send formatted/rich data (formatted text, links, images, etc) - #4
注意:我在自己的 Lintalist 程序中使用了相同的技术。
我的机器上本地保存了一个文本 htm 文件,我想使用 AutoHotKey
脚本将其内容复制到剪贴板。我试过了:
FileRead, Clipboard, *c C:\Users\%A_UserName%\AppData\Local\Temp\file.htm
和
UrlDownloadToFile, C:\Users\%A_UserName%\AppData\Local\Temp\file.htm, NewTextFile.txt
但他们都没有奏效。 我能想到的唯一解决方法是在浏览器中使用以下命令打开 htm 文件:
Run, C:\Users\%A_UserName%\AppData\Local\Temp\file.htm
and Ctrl+A and next Ctrl+C 但这并不理想。
你确定路径是正确的吗?如果你这样做:
FileRead, Clipboard, C:\Users\%A_UserName%\AppData\Local\Temp\file.htm
MsgBox %ErrorLevel%
MsgBox 说什么? "ErrorLevel is set to 0 if the load was successful. It is set to 1 if a problem occurred such as: 1) file does not exist; 2) file is locked or inaccessible; 3) the system lacks sufficient memory to load the file." 来源:https://autohotkey.com/docs/commands/FileRead.htm
您安装的是哪个版本的 AutoHotkey?如果您有一个非常旧的版本,它可能难以读取 Unicode (utf-8) 文件(不确定)。 如果可能,请务必下载并安装最新版本 https://autohotkey.com/download/
FileRead 应该可以正常工作。但是它会将HTML代码的内容读取到剪贴板。如果您想要 HTML 文件的格式化文本,例如段落、粗体、斜体、列表、表格等。您需要使用 WinClip() 库的不同技术。
- 从这里下载并解压 WinClip() 库 https://autohotkey.com/board/topic/74670-class-winclip-direct-clipboard-manipulations/
创建一个新脚本,这将读取 HTML 文件并将格式化文本读入内存并粘贴(例如在 Office 或其他接受格式化输入的程序中执行此操作) :
#Include WinClipAPI.ahk #Include WinClip.ahk wc := new WinClip WinClip.Clear() FileRead, html, C:\Users\%A_UserName%\AppData\Local\Temp\file.htm WinClip.SetHTML(html) WinClip.Paste()
来源:How to send formatted/rich data (formatted text, links, images, etc) - #4
注意:我在自己的 Lintalist 程序中使用了相同的技术。