品易云推流 关闭
文章详情页
文章 > Python高级 > 用Python制作整蛊小程序

用Python制作整蛊小程序

python程序 整蛊

头像

2021-03-30 18:58:374123浏览 · 0收藏 · 0评论

用Python制作整蛊小程序.png

下面的整蛊程序,千万不要发代码,否则就实现不了你整蛊的目的了。完成后一定要打包成一个exe程序,再发给朋友使用 。

1. 使用  pip install pyinstaller

2.打包命令:

pyinstaller -F 文件名.py

一、猜我在干啥?

while True:  n = input("猜猜我在想啥?")  print("猜错喽")

启动程序后你的朋友将永远猜不出来你在干嘛。

二、恐怖桌面

启动后电脑桌面会变成恐怖图片,并播放恐怖音乐

''
    当别人打开这个程序时,其电脑桌面会变成恐怖图片,并播放恐怖音乐
'''
import time
import pygame

import win32api
import win32con
import win32gui

#线程模块
import threading


def go():
    pygame.mixer.init()
    while True:
        for i in range(1,5):
            filePath = r"E:\pycharm project\自动化办公和鼠标键盘模拟\p"+"\\"+str(i)+".mp3"

            track = pygame.mixer.music.load(filePath)
            pygame.mixer.music.play()
            time.sleep(30)
            pygame.mixer.music.stop()

def setWallpaper(path):
    reg_key = win32api.RegOpenKeyEx(win32con.HKEY_CURRENT_USER,"Control Panel\\Desktop",0,win32con.KEY_SET_VALUE)

    win32api.RegSetValueEx(reg_key, "WallpaperStyle", 0, win32con.REG_SZ, "2")

    win32gui.SystemParametersInfo(win32con.SPI_SETDESKWALLPAPER, path, win32con.SPIF_SENDWININICHANGE)


th = threading.Thread(target=go,name="loopTread")
th.start()
while True:
    for i in range(1,5):
        filePath = r"E:\pycharm project\自动化办公和鼠标键盘模拟\p"+"\\"+str(i)+".jpg"
        setWallpaper(filePath)
        time.sleep(4)

三、打开同一网站

调用默认浏览器,打开 python学习网 ,让他爱上学习。

import webbrowserwhile True:    webbrowser.open('www.py.cn')

(推荐操作系统:windows7系统、Python 3.9.1,DELL G3电脑。)

关注

关注公众号,随时随地在线学习

本教程部分素材来源于网络,版权问题联系站长!

底部广告图