AutoHotKey:读取两个下划线键

AutoHotKey: read of two underscore keys

我的 AutoHotKey 脚本的一部分应该可以识别是否输入了 __

AutoHotKey documentation 之后,我尝试了:

~__::
  tooltip,hi world
return

并收到此错误:

Line Text: ~__::
Error: Invalid hotkey.

这没有显示错误,但仅适用于一个下划线:

~_::
  tooltip,hi world
return

这没有显示错误,但它只是清除了 __:

:*:__:: 
  tooltip,hi world
return

这显示错误 Error: Invalid hotkey.:

~:*:__:: 
  tooltip,hi world
return

这没有显示错误,但什么也没做(独库:Executehotstring):

:X:~__::
  tooltip,hi world
return

如果键入 __,此 AutoHotKey 会识别:

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

这里有 4 个可能的解决方案。我留下了一个工作,评论 out/uncomment 热键标签 adding/removing 前导分号视情况而定。

这 2 个代码块在功能上是等效的,对于 2 个备选方案,在每个块中,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