如何计算 AHK 脚本中自动热键命令 运行 的次数

How to count number of times an autohotkey command is run within an AHK script

我有一个 AHK 脚本,通常用作 shorthand 回复。例如:

::test::
 Send, Hi, this is a test.
 Return

 ::test2::
 Send, hi this is test2.
 Return

 ::test3::
 Send, hi this is test3.
 Return

我需要找到一种方法来计算和存储每个热键每天 运行 的次数。有人能帮忙吗?我有 excel 可用并且搜索了用户论坛,但找不到答案。

您可以将计数写入文件,然后在每次 运行 热字串时增加它:

::test::
 FileRead, count, count.txt
 ++count
 FileDelete, count.txt
 FileAppend, % count, count.txt
 Send, Hi, this is a test.
Return

您可以通过这种方式为每个热键创建一个文件。

或者,您可以使用 IniRead 和 IniWrite 将所有内容保存在一个文件中,还可以存储日期等可选数据。