【发布时间】:2019-10-26 12:05:01
【问题描述】:
也许很奇怪。无论如何在VS中启动项目后在运行时检测热键组合。
例如如果我按住 shift 并按 f5 或在 VS 中运行,那么我想触发一行特殊的代码。
如果您不按热键组合,则它会正常触发。
【问题讨论】:
标签: visual-studio hotkeys compiler-directives
也许很奇怪。无论如何在VS中启动项目后在运行时检测热键组合。
例如如果我按住 shift 并按 f5 或在 VS 中运行,那么我想触发一行特殊的代码。
如果您不按热键组合,则它会正常触发。
【问题讨论】:
标签: visual-studio hotkeys compiler-directives
(你用“visual studio”标记你的问题;我假设是 Windows 操作系统)
换档:
if(::GetAsyncKeyState(VK_SHIFT) < 0) // Shift down
{
// Do something ("special line of code") only if Shift down
}
大写锁定案例:
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
}
...比如放在main()中
--
【讨论】: