自动锁luogu程序源代码

本文提供了自动锁定luogu平台的程序源代码,详细解析了其工作原理和实现方法。

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

自动锁luogu程序源代码

#pragma once
#include <windows.h>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <ctime>
#include <conio.h>
using namespace std;
double wtime=0.0000;
inline void swap(char &a,char &b) {char t=a;a=b;b=t;}
void lock(int uid)
{
    char cmd[2100]="start https://luogu.org/login/lock?uid=";
    char st[210];int len=0;
    while(uid>0)
    {
        st[++len]=(uid%10)+'0';
        uid/=10;
    }
    for(int i=1;i<=len/2+1;i++) swap(st[i],st[len-i+1]);
    strcat(cmd,st+1);
    printf("%s\n",cmd);
    system(cmd);
}
void help()
{
    printf("/***********************************\n");
    printf("Author:https://blog.youkuaiyun.com/qq_40155097\n");
    printf("此程序将会在鼠标、键盘没有移动一段时间后自动锁定洛谷。\n");
    printf("直到再次按下键盘/移动鼠标后才重新判断鼠标、键盘状态。\n");
    printf("***********************************/\n");
}
#define clock (double)clock()/CLOCKS_PER_SEC
bool bj(POINT a,POINT b) {return a.x!=b.x || a.y!=b.y;}
int main()
{
    help();
    printf("请输入User ID:");
    int uid;scanf("%d",&uid);
    printf("请输入等待时间(浮点数,sec):");
    scanf("%lf",&wtime);
    printf("是否要隐藏此窗口? (Y/n)");
    char hh=getche();
    printf("\n");
    if(hh=='y' || hh=='Y')
    {
        HWND hwnd=::GetForegroundWindow();
        MoveWindow(hwnd,0,0,0,0,true);
    }
    while(1)
    {
        while(1)
        {
            double st=clock;
            bool bk=true;
            POINT cst;GetCursorPos(&cst);
            while(clock-st<=wtime)
            {
                if(kbhit()) {bk=false;break;}
                POINT hh;GetCursorPos(&hh);
                if(bj(hh,cst)) {bk=false;break;}
            }
            if(bk==true)
            {
                lock(uid);
                break;
            }
        }
        POINT cst;GetCursorPos(&cst);
        while(1)
        {
            if(kbhit()) break;
            POINT hh;GetCursorPos(&hh);
            if(bj(hh,cst)) break;
        }
    }
    return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值