在我的Autohotkey主脚本中,我有数百个这样的热字符串:
例如::fe::
::f::和
例如::fi::
::fo::幸运
::foy::幸运的是
::glo::global
gloy::globally
::ha::have
::hv::然而
通常,手动触发热字符串(例如,按ALT-9)比按下并结束字符更方便。有没有办法做到这一点?我在谷歌上没有找到任何东西,所以可能没有,但这将是有用的。
我已经阅读了hotstring选项,例如:*:但这是不同的-我想要正常的hotstring操作,但也希望在需要时手动强制它们触发。
发布于 2017-05-28 02:15:57
更新:所以您实际上正在寻找的是使用ALT+9作为结束字符。我不确定,但你可能不能使用组合键(参见hotstring doc)。我现在想不出一个真正聪明的方法来做到这一点。您可以尝试类似这样的操作
::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外包出去:
::fe::gosub forExample
forExample:
send for example
return,然后您可以在某个位置定义热键:
!9::gosub forExample如果你想更酷,可以使用函数而不是子例程。
注意:
::fe::something是的缩写形式
::fe::
send something
return发布于 2017-05-28 02:30:09
::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
}
}
}发布于 2017-05-28 16:31:22
如果您使用AutoHotkey v1.1.06+,则可以使用#InputLevel
::fe::for example
::f::and
; and so on
#InputLevel, 1 ; sending space will trigger hotstrings above this line
!F9::Send {space}编辑:
我现在看到您想要省略end char,这需要一些额外的工作
一种方法是使用其他选项复制hotstring:
::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 _另一种方法是删除末尾字符
::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
Returnhttps://stackoverflow.com/questions/44219268
复制相似问题