2

Weird one maybe. Is there anyway to detect a hotkey combo at run-time after firing up the project in VS.

E.g. If I hold shift and press f5 or run in VS then i want to fire a special line of code.

If you don't press the hotkey combo then it fires as normal.

Matt
  • 3,305
  • 11
  • 54
  • 98

1 Answers1

0

(You tagged your question with 'visual studio'; I assume Windows OS)

Shift case:

if(::GetAsyncKeyState(VK_SHIFT) < 0) // Shift down
{
    // Do something ("special line of code") only if Shift down
}

Caps Lock case:

SHORT nState = ::GetAsyncKeyState(VK_CAPITAL); // Caps Lock
bool bToggled = nState & 1;
bool bDown = nState & 0x8000;

if (bToggled)
{
    // Do something ("special line of code") only if Caps Lock toggled 
}

...place it in main(), for instance

--

Ref.: GetAsyncKeyState()

Amit G.
  • 2,546
  • 2
  • 22
  • 30