What are VK keycodes, what are SC keycodes, and what is the difference between them, in autohotkey?
1 Answers
Virtual keycodes (VK) and scan codes (SC) are not in any way unique to AutoHotkey.
Scan codes are the codes sent by the keyboard hardware when you press or release keys. These are always the same for any given physical key, regardless of system settings.
Virtual keycodes are the codes that Windows maps to scan codes to assign them meanings. A given virtual keycode generally always has the same meaning, but can be assigned to different physical keys (different scan codes) on different keyboard layouts.
When you send or press a key, it can be identified by SC, VK or both. However, AutoHotkey is designed to identify a hotkey only by SC or by VK, not both at the same time.
Scan codes of some non-standard keys are unassigned; that is, they have no VK. Sending a scan code with no VK will generally have no effect, because Windows applications usually do not assign meanings to scan codes, only to virtual keycodes. However, if you send something in the form {scNNN}
, AutoHotkey will attempt to automatically fill in the appropriate VK.
Sometimes a single VK is mapped to two scan codes. In those cases, a SC hotkey can differentiate between the two physical keys whereas a VK hotkey would be activated by both (unless a SC hotkey is also present, as that takes precedence).