使用 PostMessage 时更改 Shift 的键状态

发布于 2025-01-18 10:59:01 字数 440 浏览 3 评论 0原文

我目前正在尝试使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

老街孤人 2025-01-25 10:59:01

不要尝试直接合成键盘(或鼠标)消息。改用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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文