作者热门文章
- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
#include <windows.h>
int main()
{
// This structure will be used to create the keyboard
// input event.
INPUT ip;
// Pause for 10 seconds.
Sleep(1000*10);
// Set up a generic keyboard event.
ip.type = INPUT_KEYBOARD;
ip.ki.wScan = 0; // hardware scan code for key
ip.ki.time = 0;
ip.ki.dwExtraInfo = 0;
// Press the "F5" key
ip.ki.wVk = 0x74; // virtual-key code for the "F5" key
ip.ki.dwFlags = 0; // 0 for key press
SendInput(1, &ip, sizeof(INPUT));
// Release the "F5" key
ip.ki.dwFlags = KEYEVENTF_KEYUP; // KEYEVENTF_KEYUP for key release
SendInput(1, &ip, sizeof(INPUT));
// Exit normally
return 0;
}
上面的代码是模拟按下F5
键,但是有一些声明相关的错误。INPUT、INPUT_KEYBOARD、ip
未在此范围内声明。如何解决?
最佳答案
在不知道您使用的编译器和平台工具集的情况下,很难确定到底哪里出了问题。 Reading the fine manual说:
Header Winuser.h (include Windows.h)
你在做什么。
它还说:
A problem with INPUT using
When I try to use the INPUT structure, my compiler tells me this structure is undeclared, but I have included
<windows.h>
. After some searching, I find a solution, the<winable.h>
should also be included. I don't know why, but it works.MarrySunny
12/6/2011
尽管您最好使用最新版本的 Microsoft Visual Studio 和 Windows SDK。
关于c++ - INPUT、INPUT_KEYBOARD、ip 未在此范围内声明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22432889/
#include int main() { // This structure will be used to create the keyboard // input event.
我是一名优秀的程序员,十分优秀!