Text 自动热键:读取两个下划线键

Text 自动热键:读取两个下划线键,text,autohotkey,instant,Text,Autohotkey,Instant,我的自动热键脚本的一部分应该能够识别是否键入了\u 以下是我尝试过的: ~__:: tooltip,hi world return 得到了这个错误: Line Text: ~__:: Error: Invalid hotkey. 这不会显示错误,但仅适用于一个下划线: ~_:: tooltip,hi world return 这不会显示任何错误,但只会清除以下内容: :*:__:: tooltip,hi world return 这显示错误错误:热键无效。: ~:*:__:

我的自动热键脚本的一部分应该能够识别是否键入了
\u

以下是我尝试过的:

~__::
  tooltip,hi world
return
得到了这个错误:

Line Text: ~__::
Error: Invalid hotkey.
这不会显示错误,但仅适用于一个下划线:

~_::
  tooltip,hi world
return
这不会显示任何错误,但只会清除以下内容:

:*:__:: 
  tooltip,hi world
return
这显示错误
错误:热键无效。

~:*:__:: 
  tooltip,hi world
return
这不会显示错误,但不会执行任何操作(Doku:):


此自动热键可识别是否键入了
\u

countUnderscore :=0
~_::
     countUnderscore++
     if(countUnderscore == 2){
        tooltip, %countUnderscore% = countUnderscore
        countUnderscore := 0
      }
return

这里有4种可能的解决方案。我留下了一个可用的注释,通过适当地添加/删除前导分号来注释掉/取消注释热键标签

这两个代码块在功能上是等效的,对于这两个备选代码块,在每个代码块中,
b0
可防止自动退格,即不会删除您键入的下划线

;:*?:__:: ;deletes the underscores
:b0*?:__:: ;does not delete the underscores
SoundBeep
return

;note: the X option requires AHK v1.1.28+
;:X*?:__::SoundBeep ;deletes the underscores
;:Xb0*?:__::SoundBeep ;does not delete the underscores

这表明没有错误。它首先删除
\uuuu
,然后再次写入。但它破坏了我脚本的其他功能。因此,它对我没有用处::*:_u;::发送,_u;工具提示,hi return
;:*?:__:: ;deletes the underscores
:b0*?:__:: ;does not delete the underscores
SoundBeep
return

;note: the X option requires AHK v1.1.28+
;:X*?:__::SoundBeep ;deletes the underscores
;:Xb0*?:__::SoundBeep ;does not delete the underscores