持有CTRL时的后wm_keydown?
如果我在发送postmessage
包含wm_keydown
时将ctrl
键向下键,则与消息“混乱”。
我不明白,如果它发送ctrl
加上正在发送的消息,或者是什么?
如何复制:
启动记事本
并按住ctrl
键在代码运行时
#include <windows.h>
#include <iostream>
struct extraKeyInfo
{
unsigned short repeatCount;
unsigned char scanCode;
bool extendedKey, prevKeyState, transitionState;
operator unsigned int()
{
return repeatCount | (scanCode << 16) | (extendedKey << 24) |
(prevKeyState << 30) | (transitionState << 31);
}
};
int _tmain(int argc, _TCHAR* argv[])
{
auto hwnd = FindWindow(0, L"Untitled - Notepad");
HWND hEdit = FindWindowEx(hwnd, NULL, TEXT("Edit"), NULL);
for (char ch = 'a'; ch <= 'z'; ch++) // Output a-z in Notepad
{
short vkCode = LOBYTE(VkKeyScan(ch));
extraKeyInfo lParam = {};
lParam.scanCode = MapVirtualKey(vkCode, MAPVK_VK_TO_VSC);
PostMessage(hEdit, WM_KEYDOWN, vkCode, lParam);
lParam.repeatCount = 1;
lParam.prevKeyState = true;
lParam.transitionState = true;
PostMessage(hEdit, WM_KEYUP, vkCode, lParam);
Sleep(200);
}
}
可以以某种方式将所需的密钥仅发送到postmessage
ippertion如果我有任何钥匙吗?
If i be holding the CTRL
key down while sending a PostMessage
containing WM_KEYDOWN
it 'mess' with the message.
I couldn't understand what really happens, if it sends CTRL
plus the message being sent or what?
How to reproduce:
Launch notepad
and hold the CTRL
key while the code is running
#include <windows.h>
#include <iostream>
struct extraKeyInfo
{
unsigned short repeatCount;
unsigned char scanCode;
bool extendedKey, prevKeyState, transitionState;
operator unsigned int()
{
return repeatCount | (scanCode << 16) | (extendedKey << 24) |
(prevKeyState << 30) | (transitionState << 31);
}
};
int _tmain(int argc, _TCHAR* argv[])
{
auto hwnd = FindWindow(0, L"Untitled - Notepad");
HWND hEdit = FindWindowEx(hwnd, NULL, TEXT("Edit"), NULL);
for (char ch = 'a'; ch <= 'z'; ch++) // Output a-z in Notepad
{
short vkCode = LOBYTE(VkKeyScan(ch));
extraKeyInfo lParam = {};
lParam.scanCode = MapVirtualKey(vkCode, MAPVK_VK_TO_VSC);
PostMessage(hEdit, WM_KEYDOWN, vkCode, lParam);
lParam.repeatCount = 1;
lParam.prevKeyState = true;
lParam.transitionState = true;
PostMessage(hEdit, WM_KEYUP, vkCode, lParam);
Sleep(200);
}
}
Is possible somehow to send just the desired key into the PostMessage
independent if i have any keydown?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论