【发布时间】:2017-10-14 12:06:53
【问题描述】:
我正在尝试使用 AutoHotKey 来自动化我的一些工作。与客户对应时,我有一个我使用的模板。我创建了模板并将其复制到剪贴板并使用 AutoHotKey 脚本将其保存到文件中 - 这部分工作正常。我现在想保存剪贴板中的任何内容,加载预先保存的文件,将其粘贴到我的 Outlook 消息窗口中,然后将保存的剪贴板恢复到剪贴板。我已经尝试了几种方法但没有成功 - 通常,复制到 Outlook 的内容是剪贴板中最初的内容。以下是我尝试过的脚本:
^F5::
ClipSaved := ClipboardAll ; Save the entire clipboard to ClipSaved (Not just text)
Clipboard = ; Clear the clipboard
FileRead, Clipboard, *c <fullpath to saved file like c:\dir\file.clip>
MyErr = %ErrorLevel%
if MyErr >= 1
{
MsgBox, Unable to read case_format.clip!
}
ClipWait, 5
SendInput, ^v
Clipboard := ClipSaved ; Restore the clipboard we saved
ClipSaved = ; Free the memory in case the clipboard was very large
Return
我也尝试过使用 WinClipApi,但它也不起作用。它没有复制任何内容,我最终会从 Windows 发出“哔”声:
^F5::
WinClip.Snap( ClipSaved )
WinClip.Clear()
WinClip.Load( <full path to file like "c:\dir\file.clip"> )
ClipWait,5,
WinClip.Paste()
WinClip.Restore( ClipSaved )
Return
我尝试过混合和匹配片段(例如在 WinClip 示例中使用 FileRead AHK 命令,用 'SendInput, ^v' 代替 WinClip.Paste() 等等),但似乎没有任何效果。有什么建议吗?
【问题讨论】:
-
你想要
Clipboard := ClipSaved,而不是Clipboard = ClipSaved
标签: load clipboard autohotkey paste