更新时间:2022-06-20 02:15:58
仅供参考,因为已经在评论中回答了,您必须使用 SendInput
而不是 SendMessage
,在填充 SendInput
函数所需的 INPUT
结构时,请确保将 Flags
与 KEYEVENTF_SCANCODE
结合起来发送硬件信号而不是虚拟信号.这些将由 DirectInput 处理.来源:在 DirectInput 应用程序中使用 SendInput API 模拟键盘一个>
For reference sake, as it has already been answered in the comments, you have to use SendInput
rather than SendMessage
, when filling the INPUT
structure required for the SendInput
function make sure you combine your Flags
with KEYEVENTF_SCANCODE
to send hardware signals instead of virtual ones. These will be handled by DirectInput.
Source : Simulating Keyboard with SendInput API in DirectInput applications