【发布时间】:2019-08-20 06:39:34
【问题描述】:
我需要 Autohotkey (AHK) 将文本(括在括号内)插入到我的文本文件中。但是,我的 AHK 代码会导致错误的文本输入,具体取决于在 Notepad3 中打开或在 Emacs 中打开的文本文件上使用的代码。相对于 AHK 语法,我对括号的使用显然是错误的。
我的最小工作示例:
::ttt::
; define variables
myString = abcdf
myFile = C:\Users\myUser\notes\myFile.tex
; write variables into current file
SendInput, <<%myString%>> {enter}
SendInput, [[%myFile%]]
return
我需要的结果应该是这样的:
<< abcde>>
[[C:\Users\myUser\notes\myFile.tex]]
Emacs 在使用 Emacs 打开的文本文件上使用此脚本时,结果如下所示:
<< abcde>>
[[C:\Users\myUser\notes\myFile.tex]]]
第一行按我需要的方式写,而第二行最后添加了一个额外的“]”。
Notepad3 在使用 Notepad3 打开的文本文件上使用此脚本时,结果如下所示:
<< abcde>>
[[C:\Users\myUser\notes\myFile.tex]]< /abcde>
第一行是按我需要的方式编写的,而第二行最后添加了第一行的变体,但添加了“/”。
如何修改我的代码以使文本输入在 Notpad3 和 Emacs 中看起来都正确?
【问题讨论】:
-
在我的系统上没有这样的问题。结果看起来应该是这样。首先在独立脚本中尝试您的示例。
-
感谢测试。我上面的最小工作示例是我的独立脚本。它的行为就像我展示的那样
标签: autohotkey