使用 PostMessage 时更改 Shift 的键状态
我目前正在尝试使用 PostMessage。
我掌握了如何使用它并应用不同的键等,但我遇到了一个问题: 当我自己按下 Shift 或 Ctrl 时使用 PostMessage 时,它将是 Shift + Key 的组合按键。
在某些情况下,这不是最佳的或实际上是错误的,我想知道是否可以忽略 Shift 的 Keystate 或通过 Flags 或
PostMessage(hWnd, WM_SYSKEYDOWN, VK_S, 0);
PostMessage(hWnd, WM_SYSKEYUP, VK_S, 0);
我正在使用的东西将其设置为 No 。 我尝试过使用 WM_KEYDOWN 和 UP 或 WM_CHAR 但似乎我的应用程序对 WM_CHAR 没有反应,而 WM_KEYDOWN 的作用与 WM_SYSKEYDOWN 相同
I'm currently trying to experiment with using PostMessage.
I got the hang of how to use it and apply different keys and such but I've met a problem:
When using PostMessage while I myself am pressing Shift or Ctrl, it will be a combined Keypress of Shift + Key.
In some situations this isnt optimal or actually wrong and I was wondering if it's possible to either ignore the Keystate of Shift or set it to No through Flags or something
PostMessage(hWnd, WM_SYSKEYDOWN, VK_S, 0);
PostMessage(hWnd, WM_SYSKEYUP, VK_S, 0);
I'm using it like this.
I've tried using WM_KEYDOWN and UP or WM_CHAR but it seems like my application doesn't react to WM_CHAR and WM_KEYDOWN does the same as WM_SYSKEYDOWN
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不要尝试直接合成键盘(或鼠标)消息。改用SendInput。
但是,请注意,这仍然会将新输入添加到消息队列的末尾,因此,如果您想采取某种键组合的作用其他一些方式。
Don't try to synthesize keyboard (or mouse) messages directly. Use SendInput instead.
Note, however, that this will still add the new input to the end of the message queue, so if you want to act like a certain key combination is pressed right now you will need to handle that situation in some other manner.