在自动热键脚本中插入数据

Inserting the data in an autohotkey script

我有以下脚本可以让我在文本文件中插入一行:

^1::
     InputBox, text, fire writing, What did you achieve today?
     file := FileOpen("log.txt", "a")
     file.write(text "`n") 
     file.Close()
 return

我现在想为此添加一个日期,以便我得到 DDMMYYYY - mytext。关于我应该对此脚本进行的编辑以实现此目的有什么想法吗?

要使用 AutoHotkey 格式化日期,请查看 FormatTime 的文档。

它采用以下参数,其中 Format 是您要修改的参数:

FormatTime, OutputVar , YYYYMMDDHH24MISS, Format

在您的情况下,您的脚本将类似于以下内容:

^1::
     FormatTime, TimeString,, ddMMyyyy
     InputBox, text, fire writing, What did you achieve today?
     file := FileOpen("log.txt", "a")
     file.write(TimeString . " - " . text "`n") 
     file.Close()
 return