gpt4 book ai didi

c++ - INPUT、INPUT_KEYBOARD、ip 未在此范围内声明

转载 作者:可可西里 更新时间:2023-11-01 11:53:49 26 4
gpt4 key购买 nike

#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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com