[英]Simulating UP arrow keybd_event (not working?)
keybd_event(VK_UP, MapVirtualKey(VK_UP, 0), 0, 0); //pressed
Sleep(100);
keybd_event(VK_UP, MapVirtualKey(VK_UP, 0), KEYEVENTF_KEYUP, 0); //released
Sleep(300);
The following is not automatically pressing the UP arrow and releasing it like it should. 以下内容并不会自动按向上箭头并释放它。 Am I doing something wrong?
难道我做错了什么?
The keybd_event function is obsolete. keybd_event函数已过时。 It has been superseded by the SendInput function .
它已被SendInput函数取代。
The following code might do what you want. 以下代码可能会做您想要的。
UINT SendUpArrow()
{
INPUT input[2] = {0};
input[0].type = INPUT_KEYBOARD;
input[0].ki.wVk = VK_UP;
input[0].ki.dwFlags = 0;
input[1].type = INPUT_KEYBOARD;
input[1].ki.wVk = VK_UP;
input[1].ki.dwFlags = KEYEVENTF_KEYUP;
UINT ret = ::SendInput(_countof(input), input, sizeof(INPUT));
return ret;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.