Skip to content

Commit

Permalink
v5.30
Browse files Browse the repository at this point in the history
  • Loading branch information
ZYX committed Aug 30, 2023
1 parent 328a687 commit 66a6be6
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 4 deletions.
43 changes: 39 additions & 4 deletions notif.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@
import time
from PIL import Image
from pystray import Icon, MenuItem as item
import win32con, win32api
import threading
import pygame
import sys
import os
from winotify import Notification
import psutil

def notif(title,msg):
Notification(app_id="椰羊自动化",title=title,msg=msg,icon=os.getcwd() + "\\imgs\\icon.png").show()



def exit_program(icon, item):
icon.stop()
os._exit(0)
Expand Down Expand Up @@ -57,6 +58,39 @@ def notify():
notif(s[1].strip('\n'),s[2].strip('\n'))
last = os.path.getmtime(file_name)

running = 0

def genshin():
global running
running = 1
pygame.init()
if getattr(sys, 'frozen', False):
base_path = sys._MEIPASS
else:
base_path = os.path.abspath(".")
audio_file = os.path.join(base_path, "start.mp3")
pygame.mixer.music.load(audio_file)
initial_volume = 0.3
pygame.mixer.music.set_volume(initial_volume)
st = 0
while running:
f = 0
for process in psutil.process_iter(['name']):
if process.info['name'] == 'YuanShen.exe':
f = 1
if st == 0 and f == 1:
pygame.mixer.music.play()
st = f
time.sleep(0.1)

def start():
global running
if not running:
t_start = threading.Thread(target=genshin)
t_start.start()
else:
running = 0

def main():
# 检测程序是否已经在运行
mutex = ctypes.windll.kernel32.CreateMutexW(None, False, "YEYANG_MyProgramMutex")
Expand All @@ -70,6 +104,7 @@ def main():
menu = (
item('冒泡', maopao),
item('清零', clear),
item('原神,启动', start),
item('退出', exit_program),
)
icon.menu = menu
Expand All @@ -90,4 +125,4 @@ def main():


if __name__ == '__main__':
main()
main()
Binary file added start.mp3
Binary file not shown.

0 comments on commit 66a6be6

Please sign in to comment.