到底怎么样才能实现按钮啊啊啊啊……
我自己编了一个(已附上部分代码),但是它就是不执行if里的语句,也不知道为什么,哪位好心大佬能帮忙看看吗?
#define _CRT_SECURE_NO_WARNINGS
#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
#include<bits/stdc++.h>
#include<cmath>
#include<conio.h>
#include<iostream>
#include<windows.h>
#include<time.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
using namespace std;
POINT p;
void Color(int x)
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),x);
}
void Place(const int x, const int y)
{
COORD PlaceCursorHere;
PlaceCursorHere.X = y;
PlaceCursorHere.Y = x;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), PlaceCursorHere);
return;
}
int PlaceOfShubiaoOnChuangkou()
{
POINT p;
HANDLE hOutput = GetStdHandle(STD_OUTPUT_HANDLE);
HWND h=GetForegroundWindow();
CONSOLE_FONT_INFO consoleCurrentFont;
HANDLE hStdin = GetStdHandle(STD_INPUT_HANDLE);
DWORD mode;
GetConsoleMode(hStdin, &mode);
mode &= ~ENABLE_QUICK_EDIT_MODE;
SetConsoleMode(hStdin, mode);
if(KEY_DOWN(VK_LBUTTON))
{
POINT p;
GetCursorPos(&p);
ScreenToClient(h,&p);
GetCurrentConsoleFont(hOutput, FALSE, &consoleCurrentFont);
int x=p.x/=consoleCurrentFont.dwFontSize.X;
int y=p.y/=consoleCurrentFont.dwFontSize.Y;
printf("key down (%d,%d)\n",x,y);
}
Sleep(100);
}
int main()
{
while(1)
{
PlaceOfShubiaoOnChuangkou();
if(p.x >=0&&p.x <=6&&p.y >=13&&p.y <=15)
{
Color(2);
Place(13,0);
printf("┌┄┄┐\n");
Place(14,0);
printf(" 开始\n");
Place(15,0);
printf("└┄┄┘\n");
}
}