【问题标题】:How to count number of times an autohotkey command is run within an AHK script如何计算自动热键命令在 AHK 脚本中运行的次数
【发布时间】:2018-04-22 10:47:37
【问题描述】:

我有一个通常用作速记回复的 AHK 脚本。例如:

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

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

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

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

【问题讨论】:

    标签: arrays count autohotkey


    【解决方案1】:

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

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

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

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

    【讨论】:

    • 您好,非常感谢您的帮助。我已经尝试了上面的代码,但只是得到一个带有“newCount”字样的 txt 文件。我错过了什么吗?
    • 现在应该修复了。再试一次。
    • 嗨,不幸的是它仍然返回一个空白:(
    • 我还是说,我的意思是它现在返回一个空白的 count.txt 文件。你觉得 Ini 解决方案会更好吗?
    • 我想通了。非常感谢你们的帮助。仅供参考,它需要在 count.txt 文件中设置一个 0 的起始数字,现在它正在工作。
    猜你喜欢
    • 1970-01-01
    • 2015-07-30
    • 1970-01-01
    • 1970-01-01
    • 2016-08-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多