* prefix breaking issue

Report problems with documented functionality
User avatar
evilC
Posts: 4787
Joined: 27 Feb 2014, 12:30

* prefix breaking issue

Post by evilC » 20 Jul 2020, 13:38

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
}

swagfag
Posts: 4070
Joined: 11 Jan 2017, 17:59

Re: * prefix breaking issue

Post by swagfag » 20 Jul 2020, 17:01

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

Post Reply

Return to “Bug Reports”