Autohotkey 在新行的脚本中插入规则
我编写了以下脚本,请求输入,然后将其写入一个文件Autohotkey 在新行的脚本中插入规则,autohotkey,Autohotkey,我编写了以下脚本,请求输入,然后将其写入一个文件 ^1:: InputBox, text, fire writing, What did you achieve today? file := FileOpen("log.txt", "w") file.write(text) file.Close() 返回 这很有效。然而,我在寻找另外两件事: 应添加文本,而不是替换文本 每次输入后,我需要一个新行。所以我输入了“A”和“B”,结果应该是: A B 关于如何更改此代码以实现此目的,
^1::
InputBox, text, fire writing, What did you achieve today?
file := FileOpen("log.txt", "w")
file.write(text)
file.Close()
返回
这很有效。然而,我在寻找另外两件事:
- 应添加文本,而不是替换文本
- 每次输入后,我需要一个新行。所以我输入了“A”和“B”,结果应该是:
- “w”创建一个新文件,覆盖任何现有文件
- 使用“a”(Append)将文本追加到文件,如果文件不存在,则创建该文件
- 在附加模式下打开文件后,使用
n”)来 在追加文本后添加新行:file.Write(文本“
^1::
InputBox, text, fire writing, What did you achieve today?
file := FileOpen("log.txt", "a")
file.write(text "`n")
file.Close()
return
要编写一行程序,还可以使用。
您可以使用`n
^1::
InputBox, text, fire writing, What did you achieve today?
FileAppend, %text%`n, log.txt
return