首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何手动触发Autohotkey热串?

如何手动触发Autohotkey热串?
EN

Stack Overflow用户
提问于 2017-05-28 00:38:31
回答 3查看 761关注 0票数 1

在我的Autohotkey主脚本中,我有数百个这样的热字符串:

例如::fe::

::f::和

例如::fi::

::fo::幸运

::foy::幸运的是

::glo::global

gloy::globally

::ha::have

::hv::然而

通常,手动触发热字符串(例如,按ALT-9)比按下并结束字符更方便。有没有办法做到这一点?我在谷歌上没有找到任何东西,所以可能没有,但这将是有用的。

我已经阅读了hotstring选项,例如:*:但这是不同的-我想要正常的hotstring操作,但也希望在需要时手动强制它们触发。

EN

回答 3

Stack Overflow用户

发布于 2017-05-28 02:15:57

更新:所以您实际上正在寻找的是使用ALT+9作为结束字符。我不确定,但你可能不能使用组合键(参见hotstring doc)。我现在想不出一个真正聪明的方法来做到这一点。您可以尝试类似这样的操作

代码语言:javascript
复制
::fe::
    Transform, CtrlC, Chr, 3 ; comes from ahk input documentation, I never really understood how this is supposed to work but I guess there is a code for alt 9 as well somehow
    input, key, L1 I M ; wait for the next 1 key
    if(key==CtrlC)
        sendraw forExample
return

老生常谈:

你必须将hotstring body外包出去:

代码语言:javascript
复制
::fe::gosub forExample

forExample:
    send for example
return

,然后您可以在某个位置定义热键:

代码语言:javascript
复制
!9::gosub forExample

如果你想更酷,可以使用函数而不是子例程。

注意:

代码语言:javascript
复制
::fe::something

是的缩写形式

代码语言:javascript
复制
::fe::
     send something
return
票数 2
EN

Stack Overflow用户

发布于 2017-05-28 02:30:09

代码语言:javascript
复制
::fe::for example
::f::and
::fi::for instance
::fo::fortunate
::foy::fortunately
::glo::global
::gloy::globally
::ha::have
::hv::however

!8:: trigger_hotstring("fi")
!9:: trigger_hotstring("ha")

trigger_hotstring(hotstring){
Loop, Read, %A_ScriptFullPath%  
{
    If InStr(A_LoopReadLine, "::"hotstring "::")
    {
         SendInput, % StrSplit(A_LoopReadLine,"::"hotstring "::").2
                break
    }
}
}
票数 2
EN

Stack Overflow用户

发布于 2017-05-28 16:31:22

如果您使用AutoHotkey v1.1.06+,则可以使用#InputLevel

代码语言:javascript
复制
::fe::for example
::f::and
; and so on

#InputLevel, 1 ; sending space will trigger hotstrings above this line
!F9::Send {space}

编辑:

我现在看到您想要省略end char,这需要一些额外的工作

一种方法是使用其他选项复制hotstring:

代码语言:javascript
复制
::fe::for example
:*O:fe_::for example ; duplicate the hotstrings like so
::f::and
::fi::for instance
::fo::fortunate
; and so on

#InputLevel, 1
!9::Send _

另一种方法是删除末尾字符

代码语言:javascript
复制
::fe::for example
::f::and
::fi::for instance
::fo::fortunate
; and so on

#InputLevel, 1
!9::
Send {space}
Sleep 100 ; give it time to expand the hotstring, experiment with timing
Send {bs} ; now remove trailing space
Return
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44219268

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档