吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 16156|回复: 242
上一主题 下一主题
收起左侧

[Windows] 花哨桌面 V 1.0.0

    [复制链接]
跳转到指定楼层
楼主
2025crj 发表于 2025-5-15 10:22 回帖奖励
闲来无事学py,弄了个花哨的桌面效果
  • 花瓣飘落
  • 碰到小盆友会弹开
  • 小盆友遇到花瓣会走几步



漂亮的壁纸是之前52里面分享的,同时分享给大家哦
软件下载链接(内附源码,有需要自取)
https://www.lanzouq.com/iL98U2w9uihe
其他:
  • 自己可自定义一下
  • 不修改源码的情况下
  • 只用修改对应的图片资源,比如弄从火柴人,比如弄成雪花,比如弄成雪球,大家自己开脑洞吧
  • 如何修改源码其实也可以弄从简单的背景小游戏,无聊的时候摸摸鱼,比如弄成切水果,贪吃蛇啥的,自己拓展吧


没啥毒哦,顺手带上源码大家看哦
[Python] 纯文本查看 复制代码
001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
018
019
020
021
022
023
024
025
026
027
028
029
030
031
032
033
034
035
036
037
038
039
040
041
042
043
044
045
046
047
048
049
050
051
052
053
054
055
056
057
058
059
060
061
062
063
064
065
066
067
068
069
070
071
072
073
074
075
076
077
078
079
080
081
082
083
084
085
086
087
088
089
090
091
092
093
094
095
096
097
098
099
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
import ctypes
import os
import random
import sys
import time
 
from PyQt5.QtCore import Qt, QTimer, QPoint, QByteArray
from PyQt5.QtGui import QPainter, QColor, QPixmap, QCursor
from PyQt5.QtWidgets import QApplication, QWidget
 
 
# 新增:开机自动启动实现
def add_to_startup():
    """通过创建启动项实现开机自动启动"""
    try:
        import winshell
        from win32com.client import Dispatch
    except ImportError:
        print("请安装依赖库:pip install pywin32 winshell")
        return
 
    startup_folder = winshell.startup()  # 获取启动目录
    print("添加到启动项:", startup_folder)
    shortcut_path = os.path.join(startup_folder, "小朋友.lnk")
 
    if not os.path.exists(shortcut_path):
        shell = Dispatch('WScript.Shell')
        shortcut = shell.CreateShortCut(shortcut_path)
 
        # 判断是否是打包后的exe环境
        if getattr(sys, 'frozen', False):
            # 打包后的exe路径
            executable_path = sys.executable
        else:
            # 开发环境,使用当前脚本路径
            executable_path = os.path.abspath(__file__)
 
        # 快捷方式直接指向 .exe 文件,无需额外参数
        shortcut.Targetpath = executable_path
        shortcut.Arguments = ''  # 因为目标已经是exe,不需要参数
        shortcut.WorkingDirectory = os.path.dirname(executable_path)  # 设置工作目录为exe所在目录
 
        shortcut.save()
        print("已添加到开机启动项")
    else:
        print("已存在开机启动项")
 
 
 
# 获取桌面窗口句柄并嵌入
def get_desktop_window():
    # 查找ProgMan窗口
    progman = ctypes.windll.user32.FindWindowW('ProgMan', None)
    # 发送0x052C消息生成WorkerW窗口
    ctypes.windll.user32.SendMessageW(progman, 0x052C, 0, 0)
    hwnd = ctypes.windll.user32.FindWindowExW(None, None, 'WorkerW', None)
    while hwnd:
        # 查找包含SHELLDLL_DefView的子窗口
        shell_view = ctypes.windll.user32.FindWindowExW(hwnd, None, 'SHELLDLL_DefView', None)
        if shell_view:
            return hwnd
        hwnd = ctypes.windll.user32.FindWindowExW(None, hwnd, 'WorkerW', None)
    return None
 
 
class Snowflake:
    def __init__(self, max_width, max_height):
        self.x = random.randint(0, max_width)
        self.y = random.randint(-max_height, 0# 从屏幕上方随机位置生成
        self.vx = random.uniform(-1, 1)
        self.vy = random.uniform(0.5, 1.5# 向下飘落的速度
        self.radius = random.randint(5, 10)
        self.color = QColor(255, 255, 255, 200)
        self.pixmap = QPixmap("素材.png")
        self.pixmap = self.pixmap.scaled(self.radius * 2, self.radius * 2, Qt.KeepAspectRatio, Qt.SmoothTransformation)
 
    def move(self, max_width, max_height, mouse_pos=None):
        # 如果有鼠标位置信息,检测是否需要弹开
        if mouse_pos:
            mouse_x, mouse_y = mouse_pos
            distance = ((self.x - mouse_x) ** 2 + (self.y - mouse_y) ** 2) ** 0.5
            if distance < 100# 修改:增大鼠标影响范围阈值
                self.vx = (self.x - mouse_x) * 0.2  # 修改:增强弹开力度
                self.vy = -(self.y - mouse_y) * 0.2  # 修改:增强弹开力度
                self.x += self.vx * 3  # 修改:增强弹开力度
                self.y += self.vy * 3  # 修改:增强弹开力度
            else:
                self.x += self.vx
                self.y += self.vy
        else:
            self.x += self.vx
            self.y += self.vy
 
        # 判断是否到达地面或逃出边界
        if self.y >= max_height or self.x < 0 or self.x > max_width:
            return False  #需要销毁
        return True  # 继续存在
 
    def draw(self, painter):
        # 使用图片绘制
        # 修改:将 self.x 和 self.y 转换为整数类型
        painter.drawPixmap(QPoint(int(self.x - self.radius), int(self.y - self.radius)), self.pixmap)
 
 
class DynamicWallpaper(QWidget):
    def __init__(self):
        super().__init__()
        self.broom_pixmap_list = [
            QPixmap(os.path.join("img", f)).scaled(100, 100, Qt.KeepAspectRatio, Qt.SmoothTransformation)
            for f in sorted(
                [f for f in os.listdir("img") if f.endswith(".png")],
                key=lambda x: int(os.path.splitext(x)[0])  # 按数字排序
            )
        ]
        self.current_broom_index = 0
        self.broom_timer = QTimer(self)
        # self.broom_timer.timeout.connect(self.switch_broom_image)
        self.broom_effect_duration = 6000  # 毫秒
        self.last_collision_time = 0  # 记录最后一次触发的时间
 
        # 初始化窗口属性
        self.setWindowFlags(Qt.FramelessWindowHint | Qt.WindowTransparentForInput)
        self.setAttribute(Qt.WA_TranslucentBackground)
        self.setGeometry(0, 0, QApplication.desktop().screenGeometry().width(),
                         QApplication.desktop().screenGeometry().height())
 
        # 创建雪花
        self.snowflakes = [Snowflake(self.width(), self.height()) for _ in range(50)]  # 初始
        # 定时器更新动画
        self.timer = QTimer(self)
        self.timer.timeout.connect(self.update_snowflakes)
        self.timer.start(30)
 
        # 新增:周期性调整雪花数量的定时器
        self.snow_timer = QTimer(self)
        self.snow_timer.timeout.connect(self.adjust_snow_amount)
        self.snow_timer.start(60000# 每分钟调整一次
        self.snow_state = 0  # 0: 小, 1: 大, 2: 暴, 3: 大, 4: 小
 
        # 嵌入到桌面窗口
        desktop_hwnd = get_desktop_window()
        if desktop_hwnd:
            self.winId()  # 确保窗口句柄存在
            ctypes.windll.user32.SetParent(int(self.windowHandle().winId()), desktop_hwnd)
 
        self.mouse_pos = None
        self.broom_pixmap = QPixmap("")
        self.broom_pixmap = self.broom_pixmap.scaled(100, 100, Qt.KeepAspectRatio, Qt.SmoothTransformation)
 
    def start_random_broom_switch(self):
        current_time = self.get_current_time()
        if current_time - self.last_collision_time > self.broom_effect_duration:
            return
 
        # 随机下一次切换时间(50ms ~ 300ms)
        next_delay = random.randint(150, 250)
        QTimer.singleShot(next_delay, self.random_switch_broom)
 
    def random_switch_broom(self):
        current_time = self.get_current_time()
        if current_time - self.last_collision_time > self.broom_effect_duration:
            return
        self.current_broom_index = random.randint(0, len(self.broom_pixmap_list) - 1)
        self.update()
        # 继续下一次切换
        self.start_random_broom_switch()
 
    def get_current_time(self):
        return int(time.time() * 1000# 毫秒级时间戳
    def adjust_snow_amount(self):
        if self.snow_state == 0:
            self.snowflakes.extend([Snowflake(self.width(), self.height()) for _ in range(50)])
            self.snow_state = 1
        elif self.snow_state == 1:
            self.snowflakes.extend([Snowflake(self.width(), self.height()) for _ in range(100)])
            self.snow_state = 2
        elif self.snow_state == 2:
            self.snowflakes = self.snowflakes[:150]
            self.snow_state = 3
        elif self.snow_state == 3:
            self.snowflakes = self.snowflakes[:100]
            self.snow_state = 4
        elif self.snow_state == 4:
            self.snowflakes = self.snowflakes[:50]
            self.snow_state = 0
 
    def update_snowflakes(self):
        for flake in self.snowflakes[:]:  # 使用切片复制列表以避免修改时迭代
            if not flake.move(self.width(), self.height(), self.mouse_pos):  # 如果需要销毁
                self.snowflakes.remove(flake)  # 移除
                self.snowflakes.append(Snowflake(self.width(), self.height()))  # 在顶部生成新的
        self.update()  # 触发重绘
 
    def paintEvent(self, event):
        painter = QPainter(self)
        painter.setRenderHint(QPainter.Antialiasing)
        # 获取鼠标当前位置
        mouse_pos = QCursor.pos()
        mouse_pos = self.mapFromGlobal(mouse_pos)
        current_broom = self.broom_pixmap_list[self.current_broom_index]
        # 绘制
        painter.drawPixmap(
            mouse_pos.x() - current_broom.width() // 2 + 40,
            mouse_pos.y() + 20,
            current_broom
        )
        # 绘制
        for flake in self.snowflakes:
            # 计算距离
            distance = ((flake.x - mouse_pos.x()) ** 2 + (flake.y - mouse_pos.y()) ** 2) ** 0.5
            if distance < 60# 鼠标影响范围阈值
                flake.vx = (flake.x - mouse_pos.x()) * 0.2
                flake.vy = -(flake.y - mouse_pos.y()) * 0.2
                flake.x += flake.vx * 3
                flake.y += flake.vy * 3
                flake.color.setAlpha(255)
 
                current_time = self.get_current_time()
                if current_time - self.last_collision_time > self.broom_effect_duration:
                    self.last_collision_time = current_time
                    self.start_random_broom_switch()
 
 
            else:
                flake.color.setAlpha(200# 其他时刻保持正常透明度
 
            # 绘制雪花
            flake.draw(painter)
 
        # 绘制所有雪花后,新增绘制扫把
        painter.drawPixmap(
            mouse_pos.x() - self.broom_pixmap.width() // 2 + 40,
            mouse_pos.y() + 20# 鼠标下方20像素位置
            self.broom_pixmap
        )
 
    # 新增:捕获鼠标移动事件
    def mouseMoveEvent(self, event):
        self.mouse_pos = (event.x(), event.y())
 
 
if __name__ == '__main__':
    add_to_startup()
    # 新增:检查互斥锁
    mutex = ctypes.windll.kernel32.CreateMutexW(None, True, "Local/SnowfallProgramMutex")
    if ctypes.windll.kernel32.GetLastError() == 0x00000010:
        print("检测到程序已在运行,即将退出...")
        sys.exit(-1)
    app = QApplication(sys.argv)
    w = DynamicWallpaper()
    w.show()
    sys.exit(app.exec_())

免费评分

参与人数 56吾爱币 +53 热心值 +49 收起 理由
nani33 + 1 + 1 我很赞同!
config1994 + 1 + 1 谢谢@Thanks!
荆棘蛰 + 1 鼓励转贴优秀软件安全工具和文档!
shenxian170 + 1 我很赞同!
leonsaga + 1 + 1 谢谢@Thanks!
唐小样儿 + 1 + 1 我很赞同!
306279542 + 1 + 1 我很赞同!
gaa2001 + 1 我很赞同!
sd7225230 + 1 + 1 谢谢@Thanks!
635217113 + 1 + 1 谢谢@Thanks!
card628 + 1 热心回复!
L521W + 1 + 1 谢谢@Thanks!
Zed丶小灰狼 + 1 + 1 热心回复!
ayzl + 1 鼓励转贴优秀软件安全工具和文档!
bingohwy + 1 + 1 热心回复!
dzc999 + 1 + 1 谢谢@Thanks!
GyCz + 2 + 1 我很赞同!
开心熊猫741 + 1 + 1 热心回复!
axero117 + 1 + 1 感谢发布原创作品,吾爱破解论坛因你更精彩!
wansir + 1 + 1 谢谢@Thanks!
xiaoguai0121 + 1 + 1 谢谢@Thanks!
弑者 + 1 + 1 热心回复!
sostwo + 1 + 1 谢谢@Thanks!
jiang5886 + 1 谢谢@Thanks!
liukai102125 + 1 + 1 用心讨论,共获提升!
无尘浪子 + 1 谢谢@Thanks!
搞点什么 + 1 + 1 谢谢@Thanks!
jy00812995 + 1 + 1 谢谢@Thanks!
mhaitao + 1 + 1 我很赞同!
·夏、沫。 + 1 + 1 谢谢@Thanks!
sois + 1 + 1 谢谢@Thanks!
wang82530 + 1 + 1 鼓励转贴优秀软件安全工具和文档!
CXOrion + 1 + 1 谢谢@Thanks!
172520wan + 1 + 1 用心讨论,共获提升!
134wap + 1 + 1 谢谢@Thanks!
daoye9988 + 1 + 1 我很赞同!
Rodrian + 1 + 1 谢谢@Thanks!
ysplovewzj + 1 谢谢@Thanks!
yaan + 1 + 1 热心回复!
abc7940 + 1 + 1 谢谢@Thanks!
鸡哥带你飞 + 1 + 1 我很赞同!
苍白之白 + 1 + 1 谢谢@Thanks!
guoruihotel + 1 + 1 谢谢@Thanks!
abaooo + 1 + 1 我很赞同!
d287507968 + 1 + 1 谢谢@Thanks!
songpei + 1 + 1 谢谢@Thanks!
apull + 1 + 1 谢谢@Thanks!
芥末味彩虹 + 1 + 1 谢谢@Thanks!
CSTNJY + 1 11开启不成功
huanjimie + 1 + 1 谢谢@Thanks!
xi123456 + 1 + 1 谢谢@Thanks!
superluck2023 + 1 + 1 谢谢@Thanks!
ai19tmac + 1 + 1 好东西,值得一试
su010 + 1 我很赞同!
shengruqing + 1 我很赞同!
wanfon + 1 + 1 热心回复!

查看全部评分

本帖被以下淘专辑推荐:

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

来自 #
 楼主| 2025crj 发表于 2025-5-15 15:14 |楼主
来自 #
 楼主| 2025crj 发表于 2025-5-15 15:34 |楼主
还有其他的一些效果,半成品,大家开脑洞自己玩吧
功夫足球  火柴人 球球 星星  雾气




免费评分

参与人数 2吾爱币 +2 热心值 +2 收起 理由
lihong9639 + 1 + 1 我很赞同!
boy666 + 1 + 1 谢谢@Thanks!

查看全部评分

来自 #
 楼主| 2025crj 发表于 2025-5-22 10:58 |楼主
Along001 发表于 2025-5-22 09:58
有没有效果图看看?

有么  首页置顶评论有动图  可能加载比较慢
推荐
 楼主| 2025crj 发表于 2025-5-15 13:04 |楼主
sjg8 发表于 2025-5-15 12:19
你桌面图片中,最右边的透明的工具是什么软件?

https://t.arae.cc/p-25792/
沙发
jjddd001 发表于 2025-5-15 10:27
我竟然抢到了沙发。
3#
 楼主| 2025crj 发表于 2025-5-15 10:30 |楼主
jjddd001 发表于 2025-5-15 10:27
我竟然抢到了沙发。

优秀的你
4#
yin16 发表于 2025-5-15 10:37
那我抢个板凳吧,哈哈哈
5#
su010 发表于 2025-5-15 10:47
代码运行报错,怎么办
6#
zaozi1234 发表于 2025-5-15 10:55
看起来好高端
7#
v30 发表于 2025-5-15 10:58
怎么取消啊,小人太尬了
8#
sp3bf 发表于 2025-5-15 10:59
谢谢分享下载好资源。
9#
kawayi201314 发表于 2025-5-15 11:00
有没有效果图看看?
10#
yunkai53 发表于 2025-5-15 11:06
好玩好玩真好玩
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2025-5-30 00:56

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表