Page 1 of 1

* prefix breaking issue

Posted: 20 Jul 2020, 13:38
by evilC
There's something odd going on with this code, and the only really pattern that I can see is that using the * prefix seems to cause bugs
Specifically, with pfx := "*", then a press of backspace triggers backspace down:: but a release of backspace triggers ^backspace up::
No such problem with pfx := ""

Code: Select all

keys := ["XButton1","XButton2", "BackSpace","h","l","d","i","o","u","pgdn","pgup"]
mods := [{mod: "", label: "base"},{mod: "^", label: "ctrl"},{mod: "+", label: "shift"}]
pfx := "*"

for i, k in keys {
  for i, modobj in mods {
    keyName := modobj.mod k
    fn := Func("KeyEvent").Bind(1, modobj.label "-" k)
    hotkey, % pfx keyName, % fn
    
    fn := Func("KeyEvent").Bind(0, modobj.label "-" k)
    hotkey, % pfx keyName " up", % fn
  }
}
return

KeyEvent(state, keyName){
    Tooltip % keyName ": state: " state
}

Re: * prefix breaking issue

Posted: 20 Jul 2020, 17:01
by swagfag
minimal example

Code: Select all

#Requires AutoHotkey v1.1.33.02

; *c:: ; no difference whether commented or not

*c Up::
*^c:: ; Ctrl-C...
*^c Up::
*+c::
*+c Up:: ; ...registers as Shift-C Release

*v::
*v Up::
*^v::
*^v Up::

; leave these commented, 
; or uncomment either one or both, or add $hook hotkeys to restore correct behavior
; *+v::
; *+v Up::
	ToolTip % A_ThisHotkey
unrolled the first couple of iterations of ur loops. the bug occurs(and fixes itself) at multiple places while the loops run and hotkeys are being defined