原理:一个自动化工具,用于在指定的日期提醒用户某个人的生日。通过创建 Windows 任务计划来实现这一功能,并且能够在每年的同一天自动创建新的任务计划,确保每年都能收到提醒。主要的技术栈包括 Python、批处理文件和 Windows 任务计划。每个部分协同工作,确保任务的创建和执行都能顺利进行。
PS:火绒查毒没问题,但360那破玩意可能会报毒,懂的都知道这垃圾玩意,在python连打包一句Print“ Hello world!"都报毒,自选或看代码自己打包也行,不说了这破360了,说了就来气。
运行截图如下:
S.jpg (44.02 KB, 下载次数: 0)
下载附件
运行截图汇总
2024-11-1 11:33 上传
觉得可以的麻烦点个赞,话不多说,上链接,蓝奏云:
https://wwrd.lanzouv.com/iNt8Q2dx2j4j 密码:8it7
附代码:
[Python] 纯文本查看 复制代码# -*- coding: utf-8 -*-
import tkinter as tk
from tkinter import messagebox, simpledialog
from lunardate import LunarDate
import os
import subprocess
from datetime import datetime, timedelta
def convert_to_lunar(gregorian_date):
"""Convert Gregorian date to Lunar date."""
lunar_date = LunarDate.fromSolarDate(gregorian_date.year, gregorian_date.month, gregorian_date.day)
return lunar_date
def create_bat_file(name, birth_date):
"""Create a batch file that displays a message box with the birthday reminder and creates the next year's task."""
bat_content = f"""@echo off
title 生日提醒器
echo {name}今天生日啦!
ping localhost -n 2 >nul
pause
:: 调用创建下一年任务的批处理文件
set TASK_NAME={name}
set BIRTH_YEAR={birth_date.year}
set BIRTH_MONTH={birth_date.month}
set BIRTH_DAY={birth_date.day}
set BAT_PATH=%~dp0reminder.bat
call "%~dp0create_next_year_task.bat" "%TASK_NAME%" "%BIRTH_YEAR%" "%BIRTH_MONTH%" "%BIRTH_DAY%" "%BAT_PATH%"
"""
bat_path = os.path.join(os.getcwd(), 'reminder.bat')
with open(bat_path, 'w', encoding='gbk') as bat_file:
bat_file.write(bat_content)
print(f"Created batch file at: {bat_path}")
def calculate_next_birthday(birth_date):
"""Calculate the next birthday from today's date."""
today = datetime.now().date()
next_birthday = datetime(today.year, birth_date.month, birth_date.day).date()
if next_birthday