forked from misakamikodo/mhxy_script
-
Notifications
You must be signed in to change notification settings - Fork 0
/
game_process.py
118 lines (103 loc) · 4.66 KB
/
game_process.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
import argparse
import os
from mhxy import *
class GameProcess:
_moveOffset = (60, 20)
def __moveZhuomianbanFunc(self, size, target=None):
windows = pyautogui.getAllWindows()
zhuomianban = (71, 964, 71)
i = 0
winList = list(filter(lambda x: x.title.startswith("梦幻西游:"), windows))
if target is not None:
winList.sort(key=lambda x: (x.left / 4, x.top))
winList = [winList[min(target, len(winList)-1)]]
for item in winList:
item.activate()
log(item)
if item.left < 0:
log("notSafe")
pyautogui.moveTo(item.right - resizeOffset[0], item.bottom - resizeOffset[1])
pyautogui.dragTo(item.left + (size[0] - resizeOffset[0]), item.top + (size[1] - resizeOffset[1]),
duration=1)
pyautogui.moveTo(item.left + self._moveOffset[0], item.top + self._moveOffset[1])
cooldown(1)
sz = pyautogui.size()
# 这里任务栏写死36
no2LineTop = (sz.height-item.height-36 if sz.height-item.height*2<0 else item.height)*int(i/2)
pyautogui.dragTo(zhuomianban[i] + self._moveOffset[0], no2LineTop + self._moveOffset[1], duration=1)
i += 1
log("处理后:", item)
def moveZhuomianbanVertical(self):
windows = pyautogui.getAllWindows()
sz = pyautogui.size()
no3LineTop = (sz.height - 707 - 36 if sz.height - 707 * 3 < 0 else 707*2 + 1)
zhuomianban = (0, 707 + 1, no3LineTop)
i = 0
for item in list(filter(lambda x: x.title.startswith("梦幻西游:"), windows)):
item.activate()
log(item)
if item.left < 0:
log("notSafe")
pyautogui.moveTo(item.right - resizeOffset[0], item.bottom - resizeOffset[1])
pyautogui.dragTo(item.left + (smallSize[0] - resizeOffset[0]), item.top + (smallSize[1] - resizeOffset[1]),
duration=1)
pyautogui.moveTo(item.left + self._moveOffset[0], item.top + self._moveOffset[1])
cooldown(1)
pyautogui.dragTo(71 + self._moveOffset[0], zhuomianban[i] + self._moveOffset[1], duration=1)
i += 1
log("处理后:", item)
def moveZhuomianban(self, target=None):
self.__moveZhuomianbanFunc(smallSize, target=target)
def moveZhuomianban2Origin(self):
windows = pyautogui.getAllWindows()
item = list(filter(lambda x: x.title.startswith("梦幻西游"), windows))[0]
item.activate()
log(item)
pyautogui.moveTo(item.right - resizeOffset[0], item.bottom - resizeOffset[1])
pyautogui.dragTo(item.left + (originSize[0] - resizeOffset[0]), item.top + (originSize[1] - resizeOffset[1]),
duration=1)
cooldown(3)
log("处理后:", item)
def moveMoniqi(self):
self.__moveMoniqiFunc(smallSize)
def __moveMoniqiFunc(self, size):
windows = pyautogui.getAllWindows()
i = 0
for item in list(filter(lambda x: x.title.startswith("MuMu模拟器12") or x.title.startswith("梦幻西游 - "), windows)):
item.activate()
log(item)
if item.left < 0:
log("notSafe")
pyautogui.moveTo(item.right - 5, item.top + 15)
pyautogui.dragTo(item.left + (size[0] - 5), item.top + 15,
duration=1)
i += 1
log("处理后:", item)
def closeMoniqi(self):
#根据进程名杀死进程 NemuPlayer.exe QtWebEngineProcess.exe NemuHeadless.exe || mymain.exe CCMini.exe
pro = 'taskkill /f /im %s'% 'NemuHeadless.exe'
os.system(pro)
pro = 'taskkill /f /im %s'% 'QtWebEngineProcess.exe'
os.system(pro)
def closeZhuomianban(self):
pro = 'taskkill /f /im %s'% 'MyGame_x64r.exe'
os.system(pro)
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='OF Generate')
parser.add_argument('-s', '--size', default='small', type=str)
parser.add_argument('-d', '--direct', default='horizontal', type=str)
parser.add_argument('--type', default='zhuomian', type=str)
args = parser.parse_args()
resize = GameProcess()
if args.type == "zhuomian":
if args.size == 'small':
if args.direct == 'horizontal':
resize.moveZhuomianban()
else:
resize.moveZhuomianbanVertical()
else:
resize.moveZhuomianban2Origin()
else:
resize.moveMoniqi()
# 模拟器分辨率设置为:1600*1095 再调整窗口大小可使用脚本
# resize.moveMoniqi()