MCPcopy Create free account
hub / github.com/AutoHotkey/AutoHotkey / HotkeyToText

Method HotkeyToText

source/script_gui.cpp:9561–9596  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9559
9560
9561LPTSTR GuiType::HotkeyToText(WORD aHotkey, LPTSTR aBuf)
9562// Caller has ensured aBuf is large enough to hold any hotkey name.
9563// Returns aBuf.
9564{
9565 BYTE modifiers = HIBYTE(aHotkey); // In this case, both the VK and the modifiers are bytes, not words.
9566 LPTSTR cp = aBuf;
9567 if (modifiers & HOTKEYF_SHIFT)
9568 *cp++ = '+';
9569 if (modifiers & HOTKEYF_CONTROL)
9570 *cp++ = '^';
9571 if (modifiers & HOTKEYF_ALT)
9572 *cp++ = '!';
9573 BYTE vk = LOBYTE(aHotkey);
9574
9575 if (modifiers & HOTKEYF_EXT) // Try to find the extended version of this VK if it has two versions.
9576 {
9577 // Fix for v1.0.37.03: A virtual key that has only one scan code should be resolved by VK
9578 // rather than SC. Otherwise, Numlock will wind up being SC145 and NumpadDiv something similar.
9579 // If a hotkey control could capture AppsKey, PrintScreen, Ctrl-Break (VK_CANCEL), which it can't, this
9580 // would also apply to them.
9581 // Fix for v1.1.26.02: Check sc2 != 0, not sc1 != sc2, otherwise the fix described above doesn't work.
9582 sc_type sc2 = vk_to_sc(vk, true); // Secondary scan code.
9583 if (sc2) // Non-zero means this key has two scan codes.
9584 {
9585 sc_type sc1 = vk_to_sc(vk); // Primary scan code for this virtual key.
9586 sc_type sc = (sc2 & 0x100) ? sc2 : sc1;
9587 if (sc & 0x100)
9588 {
9589 SCtoKeyName(sc, cp, 100);
9590 return aBuf;
9591 }
9592 }
9593 }
9594 // Since above didn't return, use a simple lookup on VK, since it gives preference to non-extended keys.
9595 return VKtoKeyName(vk, cp, 100);
9596}
9597
9598
9599

Callers

nothing calls this directly

Calls 3

vk_to_scFunction · 0.85
SCtoKeyNameFunction · 0.85
VKtoKeyNameFunction · 0.85

Tested by

no test coverage detected