生死狙击2净化行动挂机脚本

本文最后更新于 2024年7月21日 晚上

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
import pyautogui
import pydirectinput
import time
import os
import sys
pyautogui.PAUSE = 0
#适用于净化行动,关闭自动匹配队友,开启单人匹配,在开始匹配页面运行程序。
######### 以管理员身份运行!!!! ###########
# 获取图片的绝对路径
def get_resource_path(relative_path):
if hasattr(sys, '_MEIPASS'):
return os.path.join(sys._MEIPASS, relative_path)
return os.path.join(os.path.abspath("."), relative_path)
#局内动作循环
def repeat_keys(keys):
try:
a = time.time()
bb = time.time()
while a-bb+5000>0:
for key in keys:
pyautogui.keyDown(key)
time.sleep(1)
pyautogui.keyUp(key)
time.sleep(9)
bb = time.time()
pyautogui.press('esc')
except KeyboardInterrupt:
print("Stopped by user")
#检测图片
def identify_picture(a):
left, top, width, height = pyautogui.locateOnScreen(get_resource_path(a),confidence=0.9,grayscale=True) # 寻找图片
center = pyautogui.center((left, top, width, height)) # 寻找图片的中心
print('开始',center)
pydirectinput.moveTo(center[0],center[1])
pydirectinput.click()
time.sleep(10)
# 4:3比例 + 无边框窗口
while True:
try:
identify_picture('img\sta1.png') #检测开始匹配
except TypeError:
try:
identify_picture('img\\bac.png') #检测返回大厅
except TypeError:
try:
identify_picture('img\\img.png') #检测准备完毕
repeat_keys(['w', 'a', 's', 'd']) #局内动作,防止强退
except TypeError:
try:
identify_picture('img\\img_1.png') #检测返回大厅(出错情况)
except TypeError:
try:
identify_picture('img\\img_2.png') #检测确定(出错情况)
except TypeError:
try:
identify_picture('img\\img_3.png') #检测点击空白处关闭(出错情况)
except TypeError:
print('无')
time.sleep(2)

生死狙击2净化行动挂机脚本
https://jimes.cn/2024/07/21/生死狙击2净化行动挂机脚本/
作者
Jimes
发布于
2024年7月21日
许可协议