Skip to content

基于C++11的Windows控制台键鼠标交互模块,支持键盘按键或鼠标点击进行交互,正在持续优化

Notifications You must be signed in to change notification settings

Necho-dev/ConsoleMenu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ConsoleMenu

开发进度

    • 键盘方向键(↑/↓)交互
    • 鼠标选择交互
    • 独立封装Menu类 (封装进行中)
    • 封装为单文件模块 hpp

使用方法详解

  • 引用Logs.h头文件
#include "lib/Logs.h"
  • 定义选项(Items) 和对应值(Values)
std::vector<std::string> Values = {"IMAGE::NONE", "IMAGE::JPG", "IMAGE::PNG", "IMAGE::BMP", "EXIT", "IMAGE::JPG"};
std::vector<std::string> Items = {"NONE", "JPG", "PNG", "BMP", "EXIT", "JPG"};
  • 调用控制台菜单 - 鼠标操作 MouseMenu()
// 控制台菜单 鼠标操作
int MouseChoice = Logs::MouseMenu(Items, "鼠标选择菜单");
  • 调用控制台菜单 - 键盘操作 selectMenu()
// 控制台菜单 键盘操作
int KeyboardChoice = Logs::selectMenu(Items, "键盘选择菜单");
  • 样例代码
#include <iostream>
#include "lib/Logs.h"


int main() {
    system("cls"); // 清屏

    std::vector<std::string> Values = {"IMAGE::NONE", "IMAGE::JPG", "IMAGE::PNG", "IMAGE::BMP", "EXIT", "IMAGE::JPG"};
    std::vector<std::string> Items = {"NONE", "JPG", "PNG", "BMP", "EXIT", "JPG"};

    // 控制台菜单 鼠标操作
    int MouseChoice = Logs::MouseMenu(Items, "鼠标选择菜单");
    std::cout << Values[MouseChoice] << std::endl;

    // 控制台菜单 键盘操作
    int KeyboardChoice = Logs::selectMenu(Items, "键盘选择菜单");
    std::cout << Values[KeyboardChoice] << std::endl;

    system("pause");
    return 0;
}

About

基于C++11的Windows控制台键鼠标交互模块,支持键盘按键或鼠标点击进行交互,正在持续优化

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published