每次按下按钮时如何发送不同的键?

How to send different keys each time a button is pressed?

所以我得到了这个代码:

Chars:= ["5","6"] , cnt:= 0

Lbutton::
    Send % Chars[cnt:= ++cnt>chars.MaxIndex() ? 1 : cnt]
    KeyWait, Lbutton    
Return

它工作正常。

如果我按下鼠标左键,它会发送 5 键。

如果我再次按下它,它将发送 6 键并再次开始。

但我想要的是,在我松开鼠标左键之前,按键是toogle。

这是一个游戏。 :D

按照规定here,这将保持按住该键直到您松开 LMB:

Chars := ["5", "6"]
, cnt := 0

LButton::Send % "{" Chars[cnt := ++cnt > chars.MaxIndex() ? 1 : cnt] " Down}"
LButton Up::Send % "{" Chars[cnt] " Up}"