WinAPI: How to get the caps lock state?

假装没事ソ 提交于 2019-11-28 11:15:53

You want the GetKeyState() function:

http://msdn.microsoft.com/en-us/library/ms646301(VS.85).aspx

with the VK_CAPITAL key code. Rest of the virtual key codes are here:

http://technet.microsoft.com/en-us/subscriptions/index/dd375731(v=vs.85).aspx

I found this link and the code snippet below that might help you

if ((GetKeyState(VK_CAPITAL) & 0x0001)!=0)
  AfxMessageBox("Caps Lock ON!");
else
  AfxMessageBox("Caps Lock OFF!");

Use GetAsyncKeyState with VK_CAPITAL (0x14)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!