C++ 模拟按键

C++ Simulate keypress

本文关键字:模拟 C++      更新时间:2023-10-16

我对C++很陌生,找不到如何模拟按键。 我想把它变成这样:

if(GetAsyncKeyState(0x52))
{
//(Make program simulate the press of number "3" key (0x33) 
}

当我单击键盘上的"R"键时,我希望程序模拟3号按键(0x33(

您可以使用SendInput()生成击键事件,就像在键盘上键入一样。您可以在此SO问题中找到更多实用信息。

您也可以尝试 SetKeyboardState((,但这只会影响当前线程。您可以在此SO问题及其答案中找到更多信息。