c++监听键盘, C++模拟键盘输入
1、方案1:
#include <windows.h>
#include <conio.h>
#include <iostream>
using namespace std;
int main()
{
system("chcp 65001 > nul");
std::cout << "Hello, CSGO Cheater!" << std::endl;
int ch;
//方案1
int stop = 1;
int first = 0;
while(true){
if(stop == 0){
std::cout << "I'm Cheating" << std::endl;
}
if(GetAsyncKeyState(VK_F12) && first){
std::cout << "Stop!" << std::endl;
stop = 1;
}else if(GetAsyncKeyState(VK_F11)&& first){
std::cout << "Cheatting" << std::endl;
stop = 0;
}
first = 1;
}
}
2、方案2:
#include <windows.h>
#include <conio.h>
#include <iostream>
using namespace std;
int main()
{
system("chcp 65001 > nul");
std::cout << "Hello, CSGO Cheater!" << std::endl;
// 方案2
int ch;
while(true){
if(_kbhit()){
ch = _getch();
cout << ch;
if (ch == 27){
break;
}
}
}
}
这个完全没有反应啊。
不知道为什么!!!!
3、GetKeyState 和GetAsyncKeyState有什么区别?
GetKeyState()和GetAsyncKeyState()的区别_FlowShell的博客-CSDN博客_易语言getasynckeystate
写的非常好!

4、参考材料

基本是这个逻辑
5、键盘编码
浙公网安备 33010602011771号