WM_KEYDOWN的lParam参数构造

构造F1的WM_KEYDOWN的lParam:

0x1 | (MapVirtualKey(VK_F1, MAPVK_VK_TO_VSC) << 16)

如果Alt也按下

0x1 | ((KF_ALTDOWN|MapVirtualKey(VK_MENU, MAPVK_VK_TO_VSC)) << 16)


构造F1的WM_KEYUP的lParam:

0x1 | ((KF_REPEAT|KF_UP|MapVirtualKey(VK_F1, MAPVK_VK_TO_VSC)) << 16)

如果Alt也按下:

0x1 | ((KF_ALTDOWN|KF_REPEAT|KF_UP|MapVirtualKey(VK_MENU, MAPVK_VK_TO_VSC)) << 16)


使用:

::PostMessage(activeWnd->m_hWnd,WM_KEYDOWN,'V',0x1|(MapVirtualKey('V', MAPVK_VK_TO_VSC) << 16));
::PostMessage(activeWnd->m_hWnd,WM_KEYUP,'V',0x1 | ((KF_REPEAT|KF_UP|MapVirtualKey('V', MAPVK_VK_TO_VSC)) << 16));

你可能感兴趣的:(C++)