Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/135.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ keybd_事件有问题 #包括“windows.h” #包括“iostream” #包括“winuser.h” 使用名称空间std; 残疾儿童; int main() { 禁用=真; cout_C++ - Fatal编程技术网

C++ keybd_事件有问题 #包括“windows.h” #包括“iostream” #包括“winuser.h” 使用名称空间std; 残疾儿童; int main() { 禁用=真; cout

C++ keybd_事件有问题 #包括“windows.h” #包括“iostream” #包括“winuser.h” 使用名称空间std; 残疾儿童; int main() { 禁用=真; cout,c++,C++,要截获键盘事件,请使用带有WH\u keyboard\u LL参数的函数 另外,keybd_事件模拟按键,但您还需要通过第二次调用keybd_事件模拟按键释放,方法是使用KEYEVENTF_KEYUP标志。从文档顶部开始:此函数已被取代。改用SendInput。如果要将Q替换为7,只需使用自动热键。:Q:7 #include "windows.h" #include "iostream" #include "winuser.h" using namespace std; bool disab

要截获键盘事件,请使用带有
WH\u keyboard\u LL
参数的函数


另外,
keybd_事件
模拟按键,但您还需要通过第二次调用
keybd_事件
模拟按键释放,方法是使用
KEYEVENTF_KEYUP
标志。

从文档顶部开始:此函数已被取代。改用SendInput。如果要将Q替换为7,只需使用自动热键。
:Q:7
#include "windows.h"
#include "iostream"
#include "winuser.h"

using namespace std;

bool disabled;

int main()
{
    disabled = true;
    cout << "Press INSERT to toggle me on/off. Initially, I am disabled." << endl;
    a:
    if(GetAsyncKeyState(VK_INSERT)){
        disabled = false;
    }
    while(disabled == true){
        goto a;
    }
    while(disabled==false){
        while(GetAsyncKeyState(0x51)){
            keybd_event(0x67,0x67,KEYEVENTF_EXTENDEDKEY, 0);
        }
    }
    return 0;
}