C++网页快捷方式代码(升级版)

文章介绍了如何使用C++在Windows控制台环境中编写一个简单的应用程序,包含动态加载的进度条和菜单,可切换至不同的网站。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

代码直接抬上---

记得点赞喔!!!

#include <Windows.h>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#define ESC 27
#define Order1 VK_LBUTTON
#define Order2 VK_RBUTTON
using namespace std;
void clean()
{
	system("cls");
}
bool DC(int key)//点击 
{
    return (GetKeyState(key) < 0) ? (true) : (false);
}
int MouseX()//鼠标位置X
{
    HANDLE hOutput = GetStdHandle(STD_OUTPUT_HANDLE);
    HWND h = GetForegroundWindow();
    CONSOLE_FONT_INFO consoleCurrentFont;
    POINT MousePosition;
    GetCursorPos(&MousePosition);
    ScreenToClient(h, &MousePosition);
    GetCurrentConsoleFont(hOutput, FALSE, &consoleCurrentFont);
    MousePosition.x /= consoleCurrentFont.dwFontSize.X;
    return MousePosition.x + 1;
}
int MouseY()//鼠标位置Y
{
    HANDLE hOutput = GetStdHandle(STD_OUTPUT_HANDLE);
    HWND h = GetForegroundWindow();
    CONSOLE_FONT_INFO consoleCurrentFont;
    POINT MousePosition;
    GetCursorPos(&MousePosition);
    ScreenToClient(h, &MousePosition);
    GetCurrentConsoleFont(hOutput, FALSE, &consoleCurrentFont);
    MousePosition.y /= consoleCurrentFont.dwFontSize.Y;
    return MousePosition.y + 1;
}
void color(int n)//颜色
{
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), n);//140灰红 
    return;
}
void gotoxy(int x, int y)
{
    COORD c;
    c.X = x - 1;
    c.Y = y - 1;
    SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), c);
}
void Loading()
{
	system("mode con cols=56 lines=5");
	HANDLE hStdin = GetStdHandle(STD_INPUT_HANDLE);
    DWORD mode;
    GetConsoleMode(hStdin, &mode);
    mode &= ~ENABLE_QUICK_EDIT_MODE;
    SetConsoleMode(hStdin, mode);
    CONSOLE_CURSOR_INFO cursor;
    cursor.bVisible = FALSE;
    cursor.dwSize = sizeof(cursor);
    HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
    SetConsoleCursorInfo(handle, &cursor);
}
int main() 
{
	int a;
	Loading();
	int start = 1, end = 8;
    for(int i = 1; i <= 250; i++,start >= 28 ? start = 1 : start ++, end >= 28 ? end = 1 : end ++) {
    	gotoxy(1,1);
    	printf("Loading...");
        gotoxy(1,3);
        if(start < end){
            for(int j = 1; j < start; j ++) {
                printf("□");//重新改一下方块(复制粘贴)
            }
            for(int j = start; j <= end; j ++) {
                printf("■");//一样的
            }
            for(int j = end + 1; j <= 28; j ++) {
                printf("□");//重新改一下方块(复制粘贴)
            }
            puts("");
        }
        if(start > end){
            for(int j = 1; j < end; j ++) {
                printf("■");//重新改一下方块(复制粘贴)
            }
            for(int j = end; j < start; j ++) {
                printf("□");//一样的
            }
            for(int j = start + 1; j <= 26; j ++) {
                printf("■");//重新改一下方块(复制粘贴)
            }
            puts("");
        }
        Sleep(20);
    }
    system("cls");
	while(1)
	{
		gotoxy(1,1);
		system("date /t");
		system("time /t");
		cout<<"-------------------------速登---------------------------"<<endl;
		cout<<"1.抖音     2.优快云     3.GitHub     4.稀土掘金     5.翻译"<<endl;
		cin>>a;
		if(a==1)
		{
			system("start https://www.douyin.com/discover");
		}
		if(a==2)
		{
			system("start https://www.youkuaiyun.com/");
		}
		if(a==3)
		{
			system("start https://www.githubs.cn/");
		}
		if(a==4)
		{
			system("start https://juejin.cn/");
		}
		if(a==5)
		{
			system("start https://fanyi.baidu.com/?fr=pcPinzhuan");
		}
		system("cls");
	}
	return 0;
}

编译条件:VS2022或DVE C++

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值