【问题标题】:Autohotkey - Copy from HTML and paste in WordAutohotkey - 从 HTML 复制并粘贴到 Word
【发布时间】:2018-04-10 07:38:51
【问题描述】:

我是 Autohotkey 的新手,所以需要你的耐心。

我有一个包含 6236 个单独 HTML 文件的文件夹;每个包含一个句子。

这些文件的名称如下:001001、001002、001003、...、001007、002001,002002、002003 等等。当然是.html文件格式。

我想写一个带有热字串的脚本,例如:

:*:001001::

:*:001002::

以此类推,这样当我在 Word 中键入 001001 时,会将 001001.html 的内容粘贴到 word 中。当我输入 001002 时,它会将 001002.html 的内容粘贴到单词中。这种方式适用于所有 6236 个文件。

你能帮我解决这个问题吗?

【问题讨论】:

标签: autohotkey


【解决方案1】:

主要代码

 loop,6236
 {
 number := 001000 + A_Index
 number := "00" . number
 temptext1 :=":*:" . number . "::"
 temptext2 := "FileRead, orgtext, C:\" . number . ".html"
 temptext3 := "SendInput % orgtext"
 temptext4 := "return"
 temptext := temptext . temptext1 . "`n" . temptext2 . "`n" . temptext3 . "`n" . temptext4 . "`n`n"
 }

FileAppend, %temptext%, C:\test.ahk

循环 1 将创建以下文本

:*:001001::
FileRead, orgtext, C:\001001.html
SendInput % orgtext
return

循环 2 将创建

:*:001002::
FileRead, orgtext, C:\001002.html
SendInput % orgtext
return

以此类推,直到 007236。您需要更改 html 文件的位置。我假设 C:\001001.html。例如,如果文件位于 C:\Program Files\Myhtmlfiles\001001.html 中,则将第 6 行编辑为:

temptext2 := "FileRead, orgtext, C:\Program Files\Myhtmlfiles\" . number . ".html"

这是一个相当长的循环,因此需要几秒钟才能完成。循环完成后,结果将保存到位于 C:\

的 test.ahk

【讨论】:

  • 上面会发送 HTML 代码,而不是 HTML 格式的文本,所以 bold text vs bold text。如论坛所述,您可以使用 WinClip() 库来执行此操作。
猜你喜欢
  • 2015-05-10
  • 1970-01-01
  • 2017-10-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多