为什么win10命令控制台程序响应不了鼠标点击???
/*此代码win8可以正确运行*/#include<windows.h>#include<stdlib.h>#include<stdio.h>intmain(intarg...
/*此代码win8可以正确运行*/
#include <windows.h>
#include <stdlib.h>
#include<stdio.h>
int main(int argc, char* argv[])
{
SetConsoleTitle("1111111111");
HANDLE hInput = GetStdHandle(STD_INPUT_HANDLE); // 获取标准输入设备句柄
INPUT_RECORD inRec;
DWORD res;
while (1)
{
ReadConsoleInput(hInput, &inRec, 1,);
if (inRec.EventType == MOUSE_EVENT && inRec.Event.MouseEvent.dwButtonState == FROM_LEFT_1ST_BUTTON_PRESSED) //鼠标左键
{
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), inRec.Event.MouseEvent.dwMousePosition);
printf("Hello World!");
}
Sleep(100);
}
return 0;
} 展开
#include <windows.h>
#include <stdlib.h>
#include<stdio.h>
int main(int argc, char* argv[])
{
SetConsoleTitle("1111111111");
HANDLE hInput = GetStdHandle(STD_INPUT_HANDLE); // 获取标准输入设备句柄
INPUT_RECORD inRec;
DWORD res;
while (1)
{
ReadConsoleInput(hInput, &inRec, 1,);
if (inRec.EventType == MOUSE_EVENT && inRec.Event.MouseEvent.dwButtonState == FROM_LEFT_1ST_BUTTON_PRESSED) //鼠标左键
{
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), inRec.Event.MouseEvent.dwMousePosition);
printf("Hello World!");
}
Sleep(100);
}
return 0;
} 展开
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励30(财富值+成长值)
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询