Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Problems with key name synonyms (Ex: Delete and Del)


  • Please log in to reply
2 replies to this topic
jballi
  • Members
  • 1029 posts
  • Last active:
  • Joined: 01 Oct 2005
v1.0.47.05

Key names with synonyms (Ex: Delete/Del, Insert/Ins, Enter/Return, etc.) are not treated as the same key when used as context-sensitive hotkeys in multiple context wrappers (hotkeys for multiple GUIs for example).

I created this script as an example.

#SingleInstance force
gui 23:add,button,w200 h100 gGUI1,GUI1
gui 23:add,button,w200 h100 gGUI2,GUI2
gui 23:show,, PrimaryGUI
return

23guiclose:
ExitApp


;------------------ GUI1
GUI1:
gui 1:-MinimizeBox
gui 1:add,Text,w250 h100,
   (ltrim join`s
    Press Enter, Escape, Backspace, Delete, or Insert to trigger
    the associated hotkey.  Note that not all of the hotkeys
    work on this GUI.
   )
gui 1:show,,GUI1
return

guiclose:
gui 1:Destroy
return

#IfWinActive GUI1
Enter::
Escape::
Backspace::
Delete::
Insert::
gui 1:+OwnDialogs
msgbox %A_ThisHotkey% button pressed for GUI1.
return
#IfWinActive


;------------------ GUI2
GUI2:
gui 2:-MinimizeBox
gui 2:add,Text,w250 h100,
   (ltrim join`s
    Press Enter, Escape, Backspace, Delete, or Insert to trigger
    the associated hotkey.  Note that not all of the hotkeys
    work on this GUI.
   )
gui 2:show,,GUI2
return

2guiclose:
gui 2:Destroy
return

#IfWinActive GUI2
Return::
Esc::
BS::
Del::
Ins::
gui 2:+OwnDialogs
msgbox %A_ThisHotkey% button pressed for GUI2.
return
#IfWinActive
Note that some of the hotkeys will fire in GUI1 and other hotkeys will fire in GUI2.

In this example, all the hotkeys for a GUI will fire if 1) all the hotkey synonyms are renamed to either the long name or the short name (it doesn't matter which one) or if 2) one of the context wrappers is commented out. For example, all of the hotkeys for GUI1 will work if the context hotkeys for GUI2 are commented out.

Thank you for your attention. Let me know if you need any additional information.

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
Sorry for the late reply.

Thanks for pointing this out. It's definitely undesirable behavior.

Unfortunately the current architecture doesn't provide any easy way to fix this. So until I or someone else does finally fix it, it has been documented as a known limitation:

When creating duplicate hotkeys, the order of modifier symbols such as ^!+# does not matter. For example, ^!c is the same as !^c. However, keys must be spelled consistently. For example, Esc is not the same as Escape for this purpose. Finally, any hotkey with a wildcard prefix (*) is entirely separate from a non-wildcard one; for example, *F1 and F1 would each have their own set of variants.

Sorry for the trouble it caused.

jballi
  • Members
  • 1029 posts
  • Last active:
  • Joined: 01 Oct 2005

Unfortunately the current architecture doesn't provide any easy way to fix this. So until I or someone else does finally fix it, it has been documented as a known limitation.

Thanks for the feedback.

I noticed this bug when I was trying to include code that contained hotkey definitions. I must have hit one of the non-working hotkeys 10 times before I accepted that it probably wasn't going to work.

Until this bug is fixed, I would recommend to anyone who uses keys that have alternate definitions (Ex: Backspace and BS) to consistently choose one or the other. I would recommend selecting the full or expanded definition (Backspace) rather than the short or abbreviated version (BS) because the short version is not always easily interpreted. After all, everyone knows that "BS" stands for "Balance Sheet". The Enter and Return keys are a bit tougher to choose from but I like Enter because that's what is written on my keyboard.