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

Function TextToSpecial

source/keyboard_mouse.cpp:4176–4262  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4174
4175
4176vk_type TextToSpecial(LPTSTR aText, size_t aTextLength, KeyEventTypes &aEventType, modLR_type &aModifiersLR
4177 , bool aUpdatePersistent)
4178// Returns vk for key-down, negative vk for key-up, or zero if no translation.
4179// We also update whatever's in *pModifiers and *pModifiersLR to reflect the type of key-action
4180// specified in <aText>. This makes it so that {altdown}{esc}{altup} behaves the same as !{esc}.
4181// Note that things like LShiftDown are not supported because: 1) they are rarely needed; and 2)
4182// they can be down via "lshift down".
4183{
4184 if (!tcslicmp(aText, _T("ALTDOWN"), aTextLength))
4185 {
4186 if (aUpdatePersistent)
4187 if (!(aModifiersLR & (MOD_LALT | MOD_RALT))) // i.e. do nothing if either left or right is already present.
4188 aModifiersLR |= MOD_LALT; // If neither is down, use the left one because it's more compatible.
4189 aEventType = KEYDOWN;
4190 return VK_MENU;
4191 }
4192 if (!tcslicmp(aText, _T("ALTUP"), aTextLength))
4193 {
4194 // Unlike for Lwin/Rwin, it seems best to have these neutral keys (e.g. ALT vs. LALT or RALT)
4195 // restore either or both of the ALT keys into the up position. The user can use {LAlt Up}
4196 // to be more specific and avoid this behavior:
4197 if (aUpdatePersistent)
4198 aModifiersLR &= ~(MOD_LALT | MOD_RALT);
4199 aEventType = KEYUP;
4200 return VK_MENU;
4201 }
4202 if (!tcslicmp(aText, _T("SHIFTDOWN"), aTextLength))
4203 {
4204 if (aUpdatePersistent)
4205 if (!(aModifiersLR & (MOD_LSHIFT | MOD_RSHIFT))) // i.e. do nothing if either left or right is already present.
4206 aModifiersLR |= MOD_LSHIFT; // If neither is down, use the left one because it's more compatible.
4207 aEventType = KEYDOWN;
4208 return VK_SHIFT;
4209 }
4210 if (!tcslicmp(aText, _T("SHIFTUP"), aTextLength))
4211 {
4212 if (aUpdatePersistent)
4213 aModifiersLR &= ~(MOD_LSHIFT | MOD_RSHIFT); // See "ALTUP" for explanation.
4214 aEventType = KEYUP;
4215 return VK_SHIFT;
4216 }
4217 if (!tcslicmp(aText, _T("CTRLDOWN"), aTextLength) || !tcslicmp(aText, _T("CONTROLDOWN"), aTextLength))
4218 {
4219 if (aUpdatePersistent)
4220 if (!(aModifiersLR & (MOD_LCONTROL | MOD_RCONTROL))) // i.e. do nothing if either left or right is already present.
4221 aModifiersLR |= MOD_LCONTROL; // If neither is down, use the left one because it's more compatible.
4222 aEventType = KEYDOWN;
4223 return VK_CONTROL;
4224 }
4225 if (!tcslicmp(aText, _T("CTRLUP"), aTextLength) || !tcslicmp(aText, _T("CONTROLUP"), aTextLength))
4226 {
4227 if (aUpdatePersistent)
4228 aModifiersLR &= ~(MOD_LCONTROL | MOD_RCONTROL); // See "ALTUP" for explanation.
4229 aEventType = KEYUP;
4230 return VK_CONTROL;
4231 }
4232 if (!tcslicmp(aText, _T("LWINDOWN"), aTextLength))
4233 {

Callers 1

SendKeysFunction · 0.85

Calls 1

tcslicmpFunction · 0.85

Tested by

no test coverage detected