-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhistorykey.py
57 lines (52 loc) · 1.87 KB
/
historykey.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import time, subprocess, win32api, psutil, os, sys, warnings
def wish_history():
powershell_command = 'Powershell.exe -executionpolicy remotesigned -File historykey.ps1'
output = subprocess.check_output(['powershell', '-Command', powershell_command], shell=True, text=True)
if "Link copied to clipboard, paste it back to paimon.moe" in output:
for i in output.split("\n"):
if 'http' in i:
output = i
win32api.MessageBox(0, output[0:50]+"..."+output[round(len(output)/2)-25:round(len(output)/2)+25]+"..."+output[-50:-1], "Link copied to clipboard")
return True
elif "Cannot find the wish history url! Make sure to open the wish history first!" in output:
warnings.warn('Cannot find the wish history url! Make sure to open the wish history first!')
return False
else:
return False
def is_true_fn():
cwf = os.path.basename(sys.argv[0])
if (cwf == 'historykey.py') or (cwf == 'historykey.exe'):
return True
return False
def is_running():
processes = psutil.process_iter()
list_proc = []
for p in processes:
if p.name() == 'historykey.exe':
list_proc.append(p.name())
num_proc = len(list_proc)
if (num_proc == 1) or ((num_proc % 2 == 0) and (num_proc > 2)):
return True
else:
return False
def is_depen_exst():
return os.path.exists("historykey.ps1")
if is_true_fn() == False:
win32api.MessageBox(0, "Unable to locate executable file", "Error")
elif is_running():
win32api.MessageBox(0, "Another Instance Is Already Running.", "Error")
elif is_depen_exst() == False:
win32api.MessageBox(0, 'Could not find dependency file "historykey.ps1"', "Error")
else:
if not wish_history():
while True:
try:
processes = psutil.pids()
for process in processes:
name = psutil.Process(process).name()
if "GenshinImpact" in name:
if wish_history():
break
except:
None
time.sleep(1)