代码之家  ›  专栏  ›  技术社区  ›  G. user17

如何将任何文字转换为Autoit命令-Hotstringset替代方案

  •  1
  • G. user17  · 技术社区  · 7 年前

    如何将任何文字转换为Autoit命令?

    此代码仅在我键入键盘热键组合时有效(但我想键入一个字来执行Autoit代码)

    热键集示例:

    HotKeySet (“{F1}”, “calc”)
    
    Func calc()
    Local $iPID = ShellExecute (“calc.exe”)
    EndFunc
    

    是否有Hotstringset替代方案。

    我现在在自动热键中你可以把任何单词变成命令。

    自动热键语言示例:

    :*:calc::
    run calc.exe
    return
    
    1 回复  |  直到 7 年前
        1
  •  2
  •   stevecody    7 年前

    有了它,你可以将任何单词转换成Autoit命令。

    步骤1-您可以下载HotStringSet。此处为zip文件。(包含在HotString.au3中) HotKeySet vs HotStringSet

    第2步-解压并手动复制热字符串。au3到路径C:\Program Files(x86)\AutoIt3\Include

    第3步-现在您可以在任何Autoit脚本中使用HotStringSet了。

    enter image description here

    您可以在键盘上键入任何文本,例如在写字板中:键入calc+Space,它将运行计算器,如果您键入kbc+Space,它将把文本kbc替换为键盘控件,如果您键入pi+Space,它将把文本pi替换为符号pi。

    编写此Autoit代码。

    #include <HotString.au3>
    
    HotKeySet ('{F1}', 'quit')
    
    HotStringSet('kbc{SPACE}', replace1)
    HotStringSet('pi{SPACE}', replace2)
    HotStringSet('calc{SPACE}', replace3)
    
    Func quit()
    Exit
    EndFunc
    
    Func replace1()
    ;MsgBox(0,'','You did typed kbc! :)')
    send ('{BS 4}keyboard control ') ; replace [kbc] into [keyboard control]
    EndFunc
    
    Func replace2()
    ;MsgBox(0,'','You did typed pi! :)')
    send ('{BS 3}{ASC 960} ') ; replace [pi] into [symbol p]
    EndFunc
    
    Func replace3()
    ;MsgBox(0,'','You did typed calc! :)')
    Local $iPID = ShellExecute ('calc.exe') ; If you type calc it wil run the application calculator.
    EndFunc
    
    While 1
    Sleep(10)
    WEnd