From bb048120bf7eaf5101b8dcc42a8864071ccdc64a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=83=E5=B6=82=E5=A4=B9=E5=9F=8E?= Date: Mon, 26 May 2025 14:41:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E4=BA=86=E8=B7=A8=E5=A4=A9?= =?UTF-8?q?=E8=AE=A1=E6=97=B6=E5=9C=A8=E4=B8=80=E4=BA=9B=E6=83=85=E5=86=B5?= =?UTF-8?q?=E4=B8=8B=E4=B8=8D=E5=BD=92=E9=9B=B6=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- selfMonitor.cpp | 138 ------------------------------------------------ 1 file changed, 138 deletions(-) diff --git a/selfMonitor.cpp b/selfMonitor.cpp index af54799..54f4e9a 100644 --- a/selfMonitor.cpp +++ b/selfMonitor.cpp @@ -1,140 +1,3 @@ -<<<<<<< HEAD -#pragma comment(linker, "/subsystem:\"Windows\" /entry:\"mainCRTStartup\"") -#include -#include -#include -#include -#include -using namespace std; -// 黑名单 -const int BLACK_LIST_SIZE = 3; -string blackList[]={"哔哩哔哩","MuMu模拟器","知乎"}; -int blackListTimeCount = 0; -const int MAX_BLACKLIST_TIME_COUNT = 1800; -const int TOLENT_MORE_TIME = 1200; -void saveData(){ - // 保存黑名单时间到save.txt - FILE *fp = fopen("save.txt", "w"); - if(fp!=NULL){ - time_t timeNow = time(0); - tm *curTime=localtime(&timeNow); - fprintf(fp, "%d %d %d %d", blackListTimeCount,curTime->tm_year,curTime->tm_mon,curTime->tm_mday); - fclose(fp); - } -} -bool beginWithMuteFlag=false; -void muteAll(){ - keybd_event(VK_SPACE, 0, 0, 0); - Sleep(1); - keybd_event(VK_SPACE, 0, KEYEVENTF_KEYUP, 0); -} -void unmuteAll(){ - keybd_event(VK_SPACE, 0, 0, 0); - Sleep(1); - keybd_event(VK_SPACE, 0, KEYEVENTF_KEYUP, 0); -} -int main(){ - ShowWindow(GetConsoleWindow(), SW_HIDE); - system("chcp 936 >>nul"); - FreeConsole(); - srand((unsigned)time(0)); - char title[1024]; - // 从save.txt中读取黑名单时间 - FILE *fp = fopen("save.txt", "r"); - if(fp!=NULL){ - int curYear,curMonth,curDay; - fscanf(fp, "%d%d%d%d", &blackListTimeCount,&curYear,&curMonth,&curDay); - time_t timeNow = time(0); - tm *curTime=localtime(&timeNow); - if(curTime->tm_year!=curYear||curTime->tm_mon!=curMonth||curTime->tm_mday!=curDay){ - blackListTimeCount = 0; - } - fclose(fp); - } - cout<<"Hello, Self Monitor!"; - while(true){ - // 判断时间如果是早上四点就重置 - time_t now = time(0); - tm *ltm = localtime(&now); - if(ltm->tm_hour==4&<m->tm_min==0){ - blackListTimeCount = 0; - } - // 获取顶层窗口名称 - HWND hwnd = GetForegroundWindow(); - if (hwnd == NULL) { - continue; - } - if(GetWindowTextA(hwnd, title, 1024) == 0){ - cout<<"GetWindowTextW failed"<=MAX_BLACKLIST_TIME_COUNT){ - muteAll(); - bool isContinue = true; - isContinue = MessageBoxA(hwnd, "半小时到了!你确定你需要继续看这个?", "半个小时提醒", MB_YESNO) == IDYES; - if(isContinue){ - MessageBoxA(hwnd, "如果你真的确定的话,按照我的指令连续点十次:", "唉,拿你没办法呢", MB_OK); - for(int i=0;i<10;i++){ - int randNum = rand()&1; - if(randNum){ - isContinue = MessageBoxA(hwnd, "先思考一下,你现在真的有用电脑的必要吗?\n你现在应该做什么?\n想好了按确认", "请思考请思考", MB_YESNO) == IDYES; - }else{ - isContinue = MessageBoxA(hwnd, "先思考一下,你现在真的有用电脑的必要吗?\n你现在应该做什么?\n想好了按取消", "请思考请思考", MB_YESNO) == IDNO; - } - if(!isContinue){ - MessageBoxA(hwnd, "看来你并没有真正下定决心呢……", "叹气……", MB_OK); - break; - } - } - } - unmuteAll(); - if(isContinue){ - MessageBoxA(hwnd, "好吧,看来你确实有急事,去忙吧,你再用二十分钟后我还会回来的!", "你先忙吧", MB_OK); - blackListTimeCount = MAX_BLACKLIST_TIME_COUNT - TOLENT_MORE_TIME; - }else{ - MessageBoxA(hwnd, "根据千嶂夹城制定的反摸鱼条例,你今天不准再摸鱼了!\n你有五秒钟保存重要文件,我数到五就强制关掉!","True Ending",MB_OK); - Sleep(5*1000); - // 强制关闭hwnd窗口 - PostMessageA(hwnd, WM_CLOSE, 0, 0); - } - }else if(blackListTimeCount%600==0){ - muteAll(); - MessageBoxA(hwnd, "你摸鱼已经十分钟了,冰澄命令你停下!", "十分钟提醒", MB_OK); - unmuteAll(); - }else if(blackListTimeCount%300==0){ - muteAll(); - MessageBoxA(hwnd, "你在摸鱼吗,又摸了五分钟了,冰澄提醒你正确休息", "五分钟提醒", MB_OK); - unmuteAll(); - } - } - // 延时 - Sleep(1000); - static int clockCount = 0; - clockCount++; - if(clockCount%60==0){ - saveData(); - } - // cout< #include @@ -274,5 +137,4 @@ int main(){ // cout<<"blackListTimeCount: "<>>>>>> dev } \ No newline at end of file