|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
通过几个API函数实现的
// MyTask.cpp : 定义控制台应用程序的入口点。
//我的任务管理器
//by 偷菜狂魔
#include <iostream>
#include <windows.h>
#include <conio.h>
using namespace std;
void Preface(); //作者说明
void show_menu(); //主菜单
int m_choice(); //菜单选择
void HideCursor() /*隐藏光标,用到了一些CONSOLE API*/
{
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_CURSOR_INFO cci;
GetConsoleCursorInfo(hOut, &cci);
cci.bVisible = FALSE;
SetConsoleCursorInfo(hOut, &cci);
}
void GotoRood(int x, int y) /*光标跳跃到某个位置,用了 CONSOLE API*/
{
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
COORD cod;
cod.X = x;
cod.Y = y;
SetConsoleCursorPosition(hOut, cod);
}
int main()
{
show_menu();
int cho = m_choice();
system("CLS");
Preface();
GotoRood(30,10);
cout<<" 您选择的是"<<cho;
getch();
return 0;
}
void show_menu()
{
Preface();
using std::cout;
HideCursor();
GotoRood(30,6);
cout<<" 显示进程";
GotoRood(30,9);
cout<<" 清除进程";
GotoRood(30,12);
cout<<" 添加白名单";
GotoRood(30,15);
cout<<" 添加黑名单";
}
void Preface()
{
GotoRood(23,0);
cout<<"控制台任务管理器 by 偷菜狂魔";
}
int m_choice() //菜单选择函数
{
GotoRood(28,6);
int cho = 6;
char ch;
cout<<"->";
while(1)
{
while(_kbhit())
{
ch = getch();
if(ch == 72)
{
if(cho == 6)
{
GotoRood(28,6);
cout<<" ";
GotoRood(28,15);
cout<<"->";
cho = 15;
}
else
{
GotoRood(28,cho);
cout<<" ";
GotoRood(28,cho-3);
cout<<"->";
cho -= 3;
}
}
if(ch == 80)
{
if(cho == 15)
{
GotoRood(28,15);
cout<<" ";
GotoRood(28,6);
cout<<"->";
cho = 6;
}
else
{
GotoRood(28,cho);
cout<<" ";
GotoRood(28,cho+3);
cout<<"->";
cho += 3;
}
}
if(ch == 13)
{
switch(cho)
{
case 6:
return 1;
case 9:
return 2;
case 12:
return 3;
case 15:
return 4;
}
}
}
}
return 0;
}
|
|