一、电脑和游戏设置:
1. 电脑桌面(2560x1440缩放125%,游戏分辨率1920x1080)
2. 游戏目录Bin及Bin64下的game.exe和Launch.exe 右键
3. 属性 - 兼容性 - 更改所有用户的设置 - 更改高dpi设置 - 勾选替换搞的dpi缩放行为 - 选应用程序。
二、功能介绍:这个只写了几个简单的功能。
home暂停/恢复
end停止
三:2560x1440分辨率脚本python代码:保存为wegame2025.py
import tkinter as tk
import pygetwindow as gw
import json
import os
import asyncio
import pyautogui
import threading
import time
import random
import win32api
import win32con
import keyboard # 新增的库
import json
import cv2
import numpy as np
from PIL import ImageGrab
# 初始化全局变量
running = True
paused = False
# 创建主窗口
root = tk.Tk()
root.title("By:樱道流衿紫")
# 假设 checkbutton_vars 是一个包含选项的字典
checkbutton_vars = {
"打死怪": tk.IntVar(),
"挂马贼": tk.IntVar(),
"加状态": tk.IntVar(),
"BB副本": tk.IntVar(),
"打绿怪": tk.IntVar(),
"打红怪": tk.IntVar(),
"峨眉饺子": tk.IntVar(),
"组队": tk.IntVar(),
"内挂": tk.IntVar(),
"升级": tk.IntVar(),
}
def activate_window():#查找游戏
windows = gw.getAllTitles()
target_windows = [title for title in windows if "新天龙八部" in title]
if target_windows:
window = gw.getWindowsWithTitle(target_windows[0])[0]
window.activate()
window.maximize()
# 使用pywin32模拟按键
def send_key_press(key):
valid_keys = ['F1','F2','F3','F4','F5','F6','F7','F8','F9','F10']
if key in valid_keys:
pyautogui.press(key) # 使用 pyautogui 发送按键
def get_pixel_colors(x,y):
screenshot = pyautogui.screenshot()
return screenshot.getpixel((x,y))
def move_at_position(x, y):
pyautogui.moveTo(x, y)
# 使用 win32api 来模拟鼠标点击
def click_at_position(screen_x,screen_y):
# 使用 win32api 进行鼠标点击
win32api.SetCursorPos((screen_x,screen_y)) # 移动鼠标到指定位置
time.sleep(random.uniform(0.03,0.04))
# 模拟鼠标点击:鼠标左键按下和释放
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,0,0,0,0) # 按下鼠标左键
time.sleep(0.02) # 按下时稍作停顿
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,0,0,0,0) # 释放鼠标左键
time.sleep(random.uniform(0.03,0.04))
def colors_are_similar(colorzz1, colorzz2, tolerance=20):
return all(abs(c1 - c2) <= tolerance for c1, c2 in zip(colorzz1, colorzz2))
def da_si_huan_guai(): #打怪
colordd2 = get_pixel_colors(1225, 1334)
colorz39 = get_pixel_colors(278, 58)
colorz310 = get_pixel_colors(279, 41)
if (colors_are_similar((126, 107, 76), colordd2, tolerance=20) and
colorz39 == (255, 162, 150) and
colorz310 != (155, 153, 152)):
send_key_press('F4')
time.sleep(random.uniform(0.07, 0.08))
colordd9 = get_pixel_colors(1261,1334)
colorz49 = get_pixel_colors(278, 58)
colorz410 = get_pixel_colors(279, 41)
if (colors_are_similar((126, 107, 76), colordd9, tolerance=20) and
colorz49 == (255, 162, 150) and
colorz410 != (155, 153, 152)):
send_key_press('F5')
time.sleep(random.uniform(0.07, 0.08))
colorddd9 = get_pixel_colors(1296,1334)
colorzz49 = get_pixel_colors(278, 58)
colorzz410 = get_pixel_colors(279, 41)
if (colors_are_similar((126, 107, 76), colorddd9, tolerance=20) and
colorzz49 == (255, 162, 150) and
colorzz410 != (155, 153, 152)):
send_key_press('F6')
time.sleep(random.uniform(0.07, 0.08))
bu_neng_gong_ji_huan_guai()
for _ in range(5): # 循环10次
colordd1 = get_pixel_colors(1189, 1334)
color9 = get_pixel_colors(278, 58)
color10 = get_pixel_colors(279, 41)
if (colors_are_similar((125, 104, 73), colordd1, tolerance=20) and
color9 == (255, 162, 150) and
color10 != (155, 153, 152)):
send_key_press('F3')
time.sleep(random.uniform(0.07, 0.08))
color1 = get_pixel_colors(278,58) # 有血
color2 = get_pixel_colors(279,41) # 白怪
if color1 == (255,162,150) and color2 != (155,153,152):
send_key_press('F2')
time.sleep(random.uniform(0.05, 0.06))
else:
send_key_press('F1')
time.sleep(random.uniform(0.05, 0.06))
color23 = get_pixel_colors(95,106)
color24 = get_pixel_colors(196,106)
if color23 == (16,4,0) and color24 != (255,162,150):
send_key_press('F10') # 如果颜色符合要求,按 F10
time.sleep(random.uniform(0.07, 0.08))
def gua_jiao_zi(): #打怪
si_wang_hui_dian2()
for _ in range(10): # 循环10次
color3 = get_pixel_colors(278, 58) # 有血
colorev3 = get_pixel_colors(447,79) # 峨眉山怪
if color3 == (255,162,150) and colorev3 == (253,249,214) : # 检查是否有绿怪
send_key_press('F2') # 假设F2是打绿怪的键
time.sleep(random.uniform(0.11, 0.13))
send_key_press('F1')
time.sleep(random.uniform(0.11, 0.13))
else:
send_key_press('F1')
time.sleep(random.uniform(0.11, 0.13))
colorpp22 = get_pixel_colors(62,32)
color22 = get_pixel_colors(83,63)
if colorpp22== (206,186,90) and color22 != (255,162,150): # 加血
send_key_press('F7') # 如果颜色符合要求,按 F7
time.sleep(random.uniform(0.07, 0.08))
def da_hong_guai(): #打怪
bu_neng_gong_ji_huan_guai()
colordd2 = get_pixel_colors(1225, 1334)
colorz39 = get_pixel_colors(278, 58)
colorz310 = get_pixel_colors(279, 41)
if (colors_are_similar((126, 107, 76), colordd2, tolerance=20) and
colorz39 == (255, 162, 150) and
colorz310 == (155, 1, 1)):
send_key_press('F4')
time.sleep(random.uniform(0.07, 0.08))
for _ in range(10): # 循环10次
colordd1 = get_pixel_colors(1189, 1334)
color9 = get_pixel_colors(278, 58)
color10 = get_pixel_colors(279, 41)
if (colors_are_similar((126, 107, 76), colordd1, tolerance=20) and
color9 == (255, 162, 150) and
color10 == (155, 1, 1)):
send_key_press('F3')
time.sleep(random.uniform(0.07, 0.08))
color1 = get_pixel_colors(278,58) # 有血
color2 = get_pixel_colors(279,41) # 红怪
if color1 == (255,162,150) and color2 == (155, 1, 1):
send_key_press('F2')
time.sleep(random.uniform(0.05, 0.06))
else:
send_key_press('F1')
time.sleep(random.uniform(0.05, 0.06))
def fang_ji_neng(): #打怪
colordd2 = get_pixel_colors(1225, 1334)
colorz39 = get_pixel_colors(278, 58)
colorz310 = get_pixel_colors(279, 41)
if (colors_are_similar((126, 107, 76), colordd2, tolerance=20) and
colorz39 == (255, 162, 150) and
colorz310 != (155, 153, 152)):
send_key_press('F4')
time.sleep(random.uniform(0.07, 0.08))
colordd9 = get_pixel_colors(1261,1334)
colorz49 = get_pixel_colors(278, 58)
colorz410 = get_pixel_colors(279, 41)
if (colors_are_similar((126, 107, 76), colordd9, tolerance=20) and
colorz49 == (255, 162, 150) and
colorz410 != (155, 153, 152)):
send_key_press('F5')
time.sleep(random.uniform(0.07, 0.08))
colorddd9 = get_pixel_colors(1296,1334)
colorzz49 = get_pixel_colors(278, 58)
colorzz410 = get_pixel_colors(279, 41)
if (colors_are_similar((126, 107, 76), colorddd9, tolerance=20) and
colorzz49 == (255, 162, 150) and
colorzz410 != (155, 153, 152)):
send_key_press('F6')
time.sleep(random.uniform(0.07, 0.08))
def da_lv_guai():
colordd2 = get_pixel_colors(1225, 1334)
colorz39 = get_pixel_colors(278, 58)
colorz310 = get_pixel_colors(279, 41)
if (colors_are_similar((126, 107, 76), colordd2, tolerance=20) and
colorz39 == (255, 162, 150) and
colorz310 != (155, 153, 152)):
send_key_press('F4')
time.sleep(random.uniform(0.07, 0.08))
colordd9 = get_pixel_colors(1261,1334)
colorz49 = get_pixel_colors(278, 58)
colorz410 = get_pixel_colors(279, 41)
if (colors_are_similar((126, 107, 76), colordd9, tolerance=20) and
colorz49 == (255, 162, 150) and
colorz410 != (155, 153, 152)):
send_key_press('F5')
time.sleep(random.uniform(0.07, 0.08))
colorddd9 = get_pixel_colors(1296,1334)
colorzz49 = get_pixel_colors(278, 58)
colorzz410 = get_pixel_colors(279, 41)
if (colors_are_similar((126, 107, 76), colorddd9, tolerance=20) and
colorzz49 == (255, 162, 150) and
colorzz410 != (155, 153, 152)):
send_key_press('F6')
time.sleep(random.uniform(0.07, 0.08))
for _ in range(10): # 循环10次
colordd1 = get_pixel_colors(1189, 1334)
color9 = get_pixel_colors(278, 58)
color10 = get_pixel_colors(279, 41)
if (colors_are_similar((126, 107, 76), colordd1, tolerance=20) and
color9 == (255, 162, 150) and
color10 != (155, 153, 152)):
send_key_press('F3')
time.sleep(random.uniform(0.07, 0.08))
color3 = get_pixel_colors(278, 58) # 有血
if color3 == (255,162,150): # 检查是否有绿怪
send_key_press('F2') # 假设F2是打绿怪的键
time.sleep(random.uniform(0.05, 0.06))
send_key_press('F1') # 默认操作
time.sleep(random.uniform(0.05, 0.06))
else:
send_key_press('F1')
time.sleep(random.uniform(0.05, 0.06))
color23 = get_pixel_colors(95,106)
color24 = get_pixel_colors(196,106)
if color23 == (16,4,0) and color24 != (255,162,150):
send_key_press('F10') # 如果颜色符合要求,按 F10
time.sleep(random.uniform(0.05, 0.06))
def fang_ji_neng2(): #打怪
colormazei1 = get_pixel_colors(453, 64) # 是马贼1
colordd1 = get_pixel_colors(1189, 1334)
color9 = get_pixel_colors(278, 58)
color10 = get_pixel_colors(279, 41)
if (colors_are_similar((125, 104, 73), colordd1, tolerance=20) and
colormazei1 == (205, 195, 196) and
color9 == (255, 162, 150) and
color10 != (155, 153, 152)):
send_key_press('F3')
time.sleep(random.uniform(0.07, 0.08))
colormazei2 = get_pixel_colors(453, 64) # 是马贼1
colordd2 = get_pixel_colors(1224, 1334)
colorz39 = get_pixel_colors(278, 58)
colorz310 = get_pixel_colors(279, 41)
if (colors_are_similar((121, 101, 69), colordd2, tolerance=20) and
colormazei2 == (205, 195, 196) and
colorz39 == (255, 162, 150) and
colorz310 != (155, 153, 152)):
send_key_press('F4')
time.sleep(random.uniform(0.07, 0.08))
def gua_ma_zei():
for _ in range(3): # 循环3次
fang_ji_neng2()
color2626 = get_pixel_colors(453, 64) # 是马贼1
color2627 = get_pixel_colors(466, 63) # 是马贼2
color2628 = get_pixel_colors(278, 58) # 有血
color2629 = get_pixel_colors(279, 41) # 白怪
if (color2626 == (205, 195, 196) and
color2627 == (179, 193, 194) and
color2628 == (255, 162, 150) and
color2629 != (155, 153, 152)): # 替换为实际颜色
send_key_press('F2')
time.sleep(random.uniform(0.05, 0.06))
else:
send_key_press('F1')
time.sleep(random.uniform(0.05, 0.06))
color23 = get_pixel_colors(95,106)
color24 = get_pixel_colors(196,106)
if color23 == (16,4,0) and color24 != (255,162,150):
send_key_press('F10') # 如果颜色符合要求,按 F10
time.sleep(random.uniform(0.07, 0.08))
def bu_neng_gong_ji_huan_guai():
color9 = get_pixel_colors(1232,149)
color10 = get_pixel_colors(1268,186)
color11 = get_pixel_colors(1234,216)
color12 = get_pixel_colors(1326,219)
if color9 == (0,255,255) and color10 == (0,255,255) and color11 == (0,255,255) and color12 == (0,255,255):
send_key_press('F1')
time.sleep(random.uniform(0.05, 0.06))
color13 = get_pixel_colors(1207,142)
color14 = get_pixel_colors(1262,167)
color15 = get_pixel_colors(1310,203)
color16 = get_pixel_colors(1358,211)
if color13 == (0,255,255) and color14 == (0,255,255) and color15 == (0,255,255) and color16 == (0,255,255):
send_key_press('F1')
time.sleep(random.uniform(0.05, 0.06))
color17 = get_pixel_colors(1258,152)
color18 = get_pixel_colors(1284,181)
color19 = get_pixel_colors(1294,203)
color20 = get_pixel_colors(1307,220)
if color17 == (0,255,255) and color18 == (0,255,255) and color19 == (0,255,255) and color20 == (0,255,255):
send_key_press('F1')
time.sleep(random.uniform(0.05, 0.06))
def zu_dui():
# 如果队伍打开 - 点击同意组队
# 如果组队闪烁,如果队伍没有打开,点击组队- 点击同意组队- 点击组队
color9124 = get_pixel_colors(1660,521) #没有打开组队界面
color9125 = get_pixel_colors(1558,836) #同意组队点
if color9124 == (248,196,88) and color9125 == (253,235,120) : # 替换为实际颜色
time.sleep(random.uniform(0.02,0.03))
click_at_position(1564,834) # 再次点击 515,540 的位置
time.sleep(random.uniform(0.2,0.3))
move_at_position(2302,174)
time.sleep(random.uniform(0.02,0.03))
color9126 = get_pixel_colors(1595,1372) #组队申请闪烁
color9127 = get_pixel_colors(1660,521) #没有打开组队界面
if color9126 == (61,54,32) and color9127 != (248,196,88) : # 替换为实际颜色
time.sleep(random.uniform(0.02,0.03))
click_at_position(1591,1370) # 点开组队
time.sleep(random.uniform(0.2,0.3))
move_at_position(2302,174)
time.sleep(random.uniform(0.02,0.03))
def jia_zhuang_tai():
colorpp21 = get_pixel_colors(62,32)
color21 = get_pixel_colors(129,69)
if colorpp21== (206,186,90) and color21 != (193,188,255): # 加蓝
send_key_press('F8') # 如果颜色符合要求,按 F8
time.sleep(random.uniform(0.07, 0.08))
colorpp22 = get_pixel_colors(62,32)
color22 = get_pixel_colors(129,63)
if colorpp22== (206,186,90) and color22 != (255,162,150): # 加血
send_key_press('F7') # 如果颜色符合要求,按 F7
time.sleep(random.uniform(0.07, 0.08))
color28 = get_pixel_colors(95,106)
color29 = get_pixel_colors(180,106)
if color28 == (16,4,0) and color29 != (255,162,150):
send_key_press('F9') # 如果颜色符合要求,按 F10
time.sleep(random.uniform(0.07, 0.08))
color23 = get_pixel_colors(95,106)
color24 = get_pixel_colors(196,106)
if color23 == (16,4,0) and color24 != (255,162,150):
send_key_press('F10') # 如果颜色符合要求,按 F10
time.sleep(random.uniform(0.07, 0.08))
def ya_biao():
colorcc1= get_pixel_colors(2499,293) #同意组队点
if colorcc1 == (249,199,91) : # 替换为实际颜色
click_at_position(2364,377)
time.sleep(random.uniform(0.02,0.03))
colorcc2= get_pixel_colors(1299,147) #传送下一站
if colorcc2 == (0,255,255) : # 替换为实际颜色
click_at_position(2349,417)
time.sleep(random.uniform(3,4))
colorcc3= get_pixel_colors(257,211) #切换地图
if colorcc3 == (250,202,95) : # 替换为实际颜色
click_at_position(94,371)
time.sleep(random.uniform(7,8))
def nei_gua():
color31 = get_pixel_colors(2543,151)
if color31 == (255,211,49):
click_at_position(2544,152)
time.sleep(random.uniform(0.23,0.25))
move_at_position(2326,129)
time.sleep(random.uniform(3,4))
si_wang_hui_dian()
duan_xian_chong_lian()
def duan_xian_chong_lian():
color34 = get_pixel_colors(1294,325)
color35 = get_pixel_colors(1176,342)
if color34 == (255,242,99) and color35 == (255,242,99):
time.sleep(random.uniform(15,18))
click_at_position(1344,361)
time.sleep(random.uniform(6,9))
find_and_activate_window() # 激活窗口
time.sleep(random.uniform(2.35,2.39))
def sheng_ji():
color30 = get_pixel_colors(1460,1329)
if color30 == (155, 152, 255) or color30 == (186, 41, 225):
click_at_position(902,1372) # 点击 589, 1099 的位置
time.sleep(random.uniform(0.25, 0.33))
new_color = get_pixel_colors(518,206) # 重新获取颜色
if new_color == (249,186,157): # 替换为你想要判断的颜色值
click_at_position(505,562) # 点击 515, 540 的位置
time.sleep(random.uniform(0.25, 0.33))
click_at_position(902,1372) # 再次点击 589, 1099 的位置
time.sleep(random.uniform(2, 3))
else:
click_at_position(902,1372) # 再次点击 589, 1099 的位置
time.sleep(random.uniform(2, 3))
def si_wang_hui_dian():
color32 = get_pixel_colors(1154,401)
color33 = get_pixel_colors(1203,403)
if color32 == (37,37,37) and color33 == (37,37,37):
time.sleep(random.uniform(10,13))
click_at_position(1357,401) # 点击 出鞘
time.sleep(random.uniform(6,8)) #
click_at_position(2501,249) # 自动寻路
time.sleep(random.uniform(0.23,0.25))
click_at_position(2446,366) # 孟婆
time.sleep(random.uniform(0.23,0.25))
click_at_position(2533,531)
time.sleep(random.uniform(4,5))
click_at_position(82,357) #大理
time.sleep(random.uniform(5,6))
click_at_position(1405,1305) #定位F9上面
time.sleep(random.uniform(0.23,0.25))
click_at_position(1354,864) #地车夫第10个
time.sleep(random.uniform(0.23,0.25))
click_at_position(1420,935) #传送
time.sleep(random.uniform(0.23,0.25))
click_at_position(1294,823)
time.sleep(random.uniform(5,6))
def si_wang_hui_dian2():
color32 = get_pixel_colors(1154,401)
color33 = get_pixel_colors(1203,403)
if color32 == (37,37,37) and color33 == (37,37,37):
os.system("shutdown /s /t 1") # Windows 系统
def fu_ben_zhuang_tai():
for _ in range(20): # 循环20次
color28 = get_pixel_colors(95,106)
color29 = get_pixel_colors(180,106)
if color28 == (16,4,0) and color29 != (255,162,150):
send_key_press('F9') # 如果颜色符合要求,按 F10
time.sleep(random.uniform(0.05, 0.06))
color23 = get_pixel_colors(95,106)
color24 = get_pixel_colors(196,106)
if color23 == (16,4,0) and color24 != (255,162,150):
send_key_press('F10') # 如果颜色符合要求,按 F10
time.sleep(random.uniform(0.05, 0.06))
def run_selected_options():
global running,paused
while running:
if not paused:
for name,var in checkbutton_vars.items():
if var.get():
try:
# 根据选项名称调用相应的功能
if name == "打死怪":
da_si_huan_guai()
elif name == "超出换怪":
bu_neng_gong_ji_huan_guai()
elif name == "加状态":
jia_zhuang_tai()
elif name == "挂马贼":
gua_ma_zei()
elif name == "打绿怪":
da_lv_guai()
elif name == "打红怪":
da_hong_guai()
elif name == "组队":
zu_dui()
elif name == "内挂":
nei_gua()
elif name == "升级":
sheng_ji()
elif name == "峨眉饺子":
gua_jiao_zi()
elif name == "BB副本":
fu_ben_zhuang_tai()
except Exception as e:
print(f"发生错误: {e}") # 处理异常
time.sleep(random.uniform(0.10,0.15))
# 启动线程
thread = threading.Thread(target=run_selected_options)
thread.daemon = True
thread.start()
print("线程已启动")
# 使用 keyboard 库捕获按键
def on_key_event(event):
global paused,running
if event.name == "home": # Home 键
paused = not paused
if paused:
status_label.config(text="状态: 已暂停")
print("执行已暂停")
else:
status_label.config(text="状态: 执行中")
print("执行已恢复")
activate_window() # 恢复时激活窗口
elif event.name == "end": # End 键
running = False
status_label.config(text="状态: 已停止")
print("脚本已停止")
# 绑定键盘事件
keyboard.on_press(on_key_event)
# 状态标签
status_label = tk.Label(root, text="状态: 正常", font=("Arial", 10))
status_label.grid(row=len(checkbutton_vars) // 2 + 3, column=0, columnspan=2, pady=(5, 5)) # 增加上边距和下边距
# 加载上次保存的勾选状态
def load_checkbutton_states():
if os.path.exists("config.json"):
with open("config.json","r") as f:
states = json.load(f)
for name,var in checkbutton_vars.items():
if name in states:
var.set(states[name])
print("勾选已加载")
# 保存勾选状态的函数
def save_checkbutton_states():
states = {name: var.get() for name,var in checkbutton_vars.items()}
with open("config.json","w") as f:
json.dump(states,f)
print("勾选已保存")
# 暂停功能
def pause():
status_label.config(text="状态: 暂停")
print("已暂停")
# 在这里添加暂停的逻辑
# 恢复功能
def resume():
status_label.config(text="状态: 恢复")
print("已恢复")
# 在这里添加恢复的逻辑
# 添加复选框到窗口,改为两列显示
for i, (text, var) in enumerate(checkbutton_vars.items()):
cb = tk.Checkbutton(root, text=text, variable=var, font=("Arial", 12), bg="#f0f0f0") # 增大字体
# 计算行和列
row = i // 2
column = i % 2
cb.grid(row=row, column=column, sticky='w', padx=15, pady=10) # 增加间距
function_text = """
功能键说明:
1、F1 切怪
2、F2 平推
3、F3-F6 技能
4、F7 加血
5、F8 加蓝
6、F9/F10 珍兽加血
7、彻地符箓放alt+9,第10个坐标
"""
function_label = tk.Label(root, text=function_text, justify='left', font=("Arial", 10), bg="#f0f0f0") # 增大字体
function_label.grid(row=(len(checkbutton_vars) // 2) + (len(checkbutton_vars) % 2) + 2, column=0, columnspan=2, padx=10, pady=(10, 10)) # 增加上下边距
# 加载上次保存的勾选状态
load_checkbutton_states()
# 添加保存按钮
save_button = tk.Button(root, text="保存勾选", command=save_checkbutton_states, font=("Arial", 12)) # 增大按钮字体
save_button.grid(row=len(checkbutton_vars) // 2 + 1, column=0, columnspan=1, pady=(5, 15), sticky='nse') # 靠上并居中显示
# 自动执行查找和激活窗口
activate_window()
# 运行主循环
root.mainloop()
python代码使用方法:
1. 电脑安装python3.8.5
腾讯软件中心-海量软件高速免费下载-软件搜索结果
2. 先设置国内pip源,保存为 pip.bat批处理运行
@echo off
echo 正在配置 pip 的阿里云镜像源...
:: 检查 pip.ini 文件是否存在
if not exist "%APPDATA%\pip" (
mkdir "%APPDATA%\pip"
)
:: 备份原配置文件
if exist "%APPDATA%\pip\pip.ini" (
copy "%APPDATA%\pip\pip.ini" "%APPDATA%\pip\pip.ini.bak" >nul
echo 已备份原配置文件为 pip.ini.bak
)
:: 写入阿里云镜像源配置
(
echo [global]
echo index-url = https://mirrors.aliyun.com/pypi/simple/
) > "%APPDATA%\pip\pip.ini"
echo pip 的阿里云镜像源设置完成!
pause
3. 安装pip包
@echo off
echo ==== Upgrading pip ====
python.exe -m pip install --upgrade pip
if errorlevel 1 (
echo Error: Failed to upgrade pip.
pause
exit /b
)
:: 安装 Python 包
echo ==== Installing packages ====
pip install pygetwindow
pip install pyautogui
pip install pyinstaller
pip install keyboard
pip install opencv-python
pip install numpy
pip install pillow
pip install pywin32
pip install asyncio
if errorlevel 1 (
echo Error: Failed to install one or more packages.
pause
exit /b
)
echo ==== All packages installed successfully ====
pause
4. 直接运行python wegame2025.py 即可运行出图形化界面
5. 打包exe:也可以像我一样直接打包成exe
@echo off
pyinstaller --onefile --windowed --icon=D:\work\Windows_107.ico wegame2025.py
pause
Windows_107.ico 也可以自己随便找个ico代替。
一、电脑和游戏设置:
1. 电脑桌面(1920x1080,游戏分辨率1920x1080)无需设置
二、功能介绍: 2560x1440的偷懒了。就写几个常用的。
峨眉自动加血没测试,不过应该不会有问题。
三:1920x1080分辨率脚本python代码:保存为wegame2025.py
import asyncio
import cv2
import json # 去掉重复导入
import numpy as np
import os
import pyautogui
import pygetwindow as gw
import random
import threading
import time
import win32api
import win32con
import keyboard
from PIL import ImageGrab
import tkinter as tk
# 初始化全局变量
running = True
paused = False
# 创建主窗口
root = tk.Tk()
root.title("By:樱道流衿紫")
# 假设 checkbutton_vars 是一个包含选项的字典
checkbutton_vars = {
"打死换怪": tk.IntVar(),
"挂马贼": tk.IntVar(),
"超出换怪": tk.IntVar(),
"打绿怪": tk.IntVar(),
"加状态": tk.IntVar(),
"内挂": tk.IntVar(),
"升级": tk.IntVar(),
"死亡回点": tk.IntVar(),
"放技能F3": tk.IntVar(),
"珍兽出战": tk.IntVar(),
"放技能F4": tk.IntVar(),
"短线重连": tk.IntVar(),
"自动组队": tk.IntVar(),
"峨眉加血": tk.IntVar(),
"半上架": tk.IntVar(),
"半抢小": tk.IntVar(),
}
def activate_window():#查找游戏
windows = gw.getAllTitles()
target_windows = [title for title in windows if "新天龙八部" in title]
if target_windows:
window = gw.getWindowsWithTitle(target_windows[0])[0]
window.activate()
window.maximize()
# 使用pywin32模拟按键
def send_key_press(key):
valid_keys = ['F1','F2','F3','F4','F5','F6','F7','F8','F9','F10']
if key in valid_keys:
pyautogui.press(key) # 使用 pyautogui 发送按键
# 定义坐标颜色大约等于
def get_pixel_colors(x,y):
screenshot = pyautogui.screenshot()
return screenshot.getpixel((x,y))
def move_at_position(x, y):
pyautogui.moveTo(x, y)
# 使用 win32api 来模拟鼠标点击
def click_at_position(screen_x,screen_y):
# 使用 win32api 进行鼠标点击
win32api.SetCursorPos((screen_x,screen_y)) # 移动鼠标到指定位置
time.sleep(random.uniform(0.04,0.05))
# 模拟鼠标点击:鼠标左键按下和释放
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,0,0,0,0) # 按下鼠标左键
time.sleep(0.03) # 按下时稍作停顿
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,0,0,0,0) # 释放鼠标左键
time.sleep(random.uniform(0.04,0.05))
def da_si_huan_guai(): #打怪
for _ in range(2): # 循环两次
color1 = get_pixel_colors(278,51)
color2 = get_pixel_colors(279,44)
if color1 == (255,162,150) and color2 != (155,153,152):
send_key_press('F2')
time.sleep(random.uniform(0.07,0.11))
else:
send_key_press('F1')
time.sleep(random.uniform(0.07,0.11))
def da_lv_guai():
for _ in range(3): # 循环两次
color3 = get_pixel_colors(278,51)
color4 = get_pixel_colors(279,44)
if color3 == (255,162,150) and color4 == (2,153,1):
send_key_press('F2')
time.sleep(random.uniform(0.07,0.11))
else:
send_key_press('F1')
time.sleep(random.uniform(0.07,0.11))
def bu_neng_gong_ji_huan_guai():
color9 = get_pixel_colors(887,108)
color10 = get_pixel_colors(938,149)
color11 = get_pixel_colors(1006,167)
color12 = get_pixel_colors(1038,182)
if color9 == (0,255,255) and color10 == (0,255,255) and color11 == (0,255,255) and color12 == (0,255,255):
send_key_press('F1')
time.sleep(random.uniform(0.07,0.11))
color13 = get_pixel_colors(1006,115)
color14 = get_pixel_colors(974,135)
color15 = get_pixel_colors(942,163)
color16 = get_pixel_colors(912,183)
if color13 == (0,255,255) and color14 == (0,255,255) and color15 == (0,255,255) and color16 == (0,255,255):
send_key_press('F1')
time.sleep(random.uniform(0.07,0.11))
color17 = get_pixel_colors(944,111)
color18 = get_pixel_colors(965,145)
color19 = get_pixel_colors(941,186)
color20 = get_pixel_colors(985,182)
if color17 == (0,255,255) and color18 == (0,255,255) and color19 == (0,255,255) and color20 == (0,255,255):
send_key_press('F1')
time.sleep(random.uniform(0.07,0.11))
def colors_are_similar2(color221,color222,tolerance=10):
return all(abs(c221 - c222) <= tolerance for c221,c222 in zip(color221,color222))
def fang_ji_neng_F3():
color221 = get_pixel_colors(869,994)
color9 = get_pixel_colors(278,51)
color10 = get_pixel_colors(279,44)
if (colors_are_similar2((125,104,73),color221,tolerance=10) and
color9 == (255,162,150) and
color10 != (155,153,152)):
send_key_press('F3')
time.sleep(random.uniform(0.6,0.9))
def colors_are_similar(color121,color122,tolerance=10):
return all(abs(c121 - c122) <= tolerance for c121,c122 in zip(color121,color122))
def fang_ji_neng_F4():
color121 = get_pixel_colors(905,994)
color9 = get_pixel_colors(278,51)
color10 = get_pixel_colors(279,44)
if (colors_are_similar((140,109,62),color121,tolerance=10) and
color9 == (255,162,150) and
color10 != (155,153,152)):
send_key_press('F4')
time.sleep(random.uniform(0.6,0.9))
def jia_zhuang_tai():
color21 = get_pixel_colors(136,56)
if color21 == (33,32,33): # 没血加血
send_key_press('F7') # 如果颜色符合要求,按 F7
time.sleep(random.uniform(0.6,0.9))
color28 = get_pixel_colors(95,99)
color29 = get_pixel_colors(167,99)
if color28 == (16,4,0) and color29 != (255,162,150):
send_key_press('F9') # 如果颜色符合要求,按 F10
time.sleep(random.uniform(0.6,0.9))
color22 = get_pixel_colors(123,63)
if color22 == (8,8,8): # 没蓝加蓝
send_key_press('F8') # 如果颜色符合要求,按 F8
time.sleep(random.uniform(0.6,0.9))
color23 = get_pixel_colors(95,99)
color24 = get_pixel_colors(195,99)
if color23 == (16,4,0) and color24 == (11,11,11):
send_key_press('F10') # 如果颜色符合要求,按 F10
time.sleep(random.uniform(0.6,0.9))
def nei_gua():
color31 = get_pixel_colors(1904,144)
if color31 == (255,211,49):
click_at_position(1905,146)
time.sleep(random.uniform(0.4,0.6))
move_at_position(1695,104)
time.sleep(random.uniform(3,4))
def si_wang_hui_dian():
color32 = get_pixel_colors(833,326)
color33 = get_pixel_colors(885,325)
if color32 == (37,37,37) and color33 == (37,37,37):
time.sleep(random.uniform(10,13))
click_at_position(1037,328) # 点击 出鞘
time.sleep(random.uniform(6,8)) #
click_at_position(1860,247) # 自动寻路
time.sleep(random.uniform(0.4,0.6))
click_at_position(1804,358) # 孟婆
time.sleep(random.uniform(0.4,0.6))
click_at_position(1892,490)
time.sleep(random.uniform(4,5))
click_at_position(77,305) #大理
time.sleep(random.uniform(5,6))
click_at_position(1085,966) #定位F9上面
time.sleep(random.uniform(0.4,0.6))
click_at_position(1041,689) #地车夫第10个
time.sleep(random.uniform(0.4,0.6))
click_at_position(1100,761) #传送
time.sleep(random.uniform(0.4,0.6))
click_at_position(974,650)
time.sleep(random.uniform(5,6))
def duan_xian_chong_lian():
color34 = get_pixel_colors(974,252)
color35 = get_pixel_colors(856,269)
if color34 == (255,242,99) and color35 == (255,242,99):
time.sleep(random.uniform(15,18))
click_at_position(1025,289)
time.sleep(random.uniform(6,9))
find_and_activate_window() # 激活窗口
time.sleep(random.uniform(2.35,2.39))
def zhen_shou_chu_zhan():
color36 = get_pixel_colors(582,159)
if color36 == (249,186,157): # 比较两个点的颜色
click_at_position(650,1032) # 点击 650,1032 的位置
time.sleep(random.uniform(1,2))
color38 = get_pixel_colors(95,99)
color39 = get_pixel_colors(82,56)
if color38 != (16,4,0) and color39 == (255,162,150): # 注意:这里的逗号要使用英文逗号
click_at_position(650,1032) # 点击 650,1032 的位置
time.sleep(random.uniform(0.6,0.9))
click_at_position(191,463) # 点击 191,463 的位置
time.sleep(random.uniform(0.6,0.9))
click_at_position(192,497) # 点击 192,497 的位置
time.sleep(random.uniform(3,4))
click_at_position(650,1032) # 再次点击 650,1032 的位置
time.sleep(random.uniform(1,2))
def sheng_ji():
color30 = get_pixel_colors(1140, 989)
if color30 == (155, 152, 255) or color30 == (186, 41, 225):
click_at_position(581, 1032) # 点击 589, 1099 的位置
time.sleep(random.uniform(0.25, 0.33))
new_color = get_pixel_colors(511,165) # 重新获取颜色
if new_color == (248,196,88): # 替换为你想要判断的颜色值
click_at_position(507, 519) # 点击 515, 540 的位置
time.sleep(random.uniform(0.25, 0.33))
click_at_position(581, 1032) # 再次点击 589, 1099 的位置
time.sleep(random.uniform(2, 3))
else:
click_at_position(581, 1032) # 再次点击 589, 1099 的位置
time.sleep(random.uniform(2, 3))
def e_mei_jia_xue():
for _ in range(3): # 循环两次
color23 = get_pixel_colors(95,99)
color24 = get_pixel_colors(195,99)
if color23 == (16,4,0) and color24 == (11,11,11):
send_key_press('F10') # 如果颜色符合要求,按 F10
time.sleep(random.uniform(0.6,0.9))
color61 = get_pixel_colors(5,150) # 队友1在
color62 = get_pixel_colors(100,150) # 队友1半血
if color61 ==(0,0,0) and color62 != (255,162,150):
click_at_position(21,166) # 点击 589,1099 的位置
time.sleep(random.uniform(0.04,0.5))
send_key_press('F2')
time.sleep(random.uniform(1.05,1.13))
click_at_position(959,575)
time.sleep(random.uniform(0.07,0.11))
color63 = get_pixel_colors(5,195) # 队友2在
color64 = get_pixel_colors(100,195) # 队友2半血
if color63 == (0,0,0) and color64 != (255,162,150):
click_at_position(21,211) # 点击 589,1099 的位置
time.sleep(random.uniform(0.04,0.5))
send_key_press('F2')
time.sleep(random.uniform(1.05,1.13))
click_at_position(959,575)
time.sleep(random.uniform(0.07,0.11))
color65 = get_pixel_colors(5,240) # 队友3在
color66 = get_pixel_colors(100,240) # 队友3半血
if color65 == (0,0,0) and color66 != (255,162,150):
click_at_position(22,253) # 点击 589,1099 的位置
time.sleep(random.uniform(0.04,0.5))
send_key_press('F2')
time.sleep(random.uniform(1.05,1.13))
click_at_position(959,575)
time.sleep(random.uniform(0.07,0.11))
color67 = get_pixel_colors(5,285) # 队友4在
color68 = get_pixel_colors(100,285) # 队友4半血
if color67 == (0,0,0) and color68 != (255,162,150):
click_at_position(25,301) # 点击 589,1099 的位置
time.sleep(random.uniform(0.04,0.5))
send_key_press('F2')
time.sleep(random.uniform(1.05,1.13))
click_at_position(959,575)
time.sleep(random.uniform(0.07,0.11))
color69 = get_pixel_colors(5,330) # 队友5在
color70 = get_pixel_colors(100,330) # 队友5半血
if color69 == (0,0,0) and color70 != (255,162,150):
click_at_position(26,345)
time.sleep(random.uniform(0.04,0.5))
send_key_press('F2')
time.sleep(random.uniform(1.05,1.13))
click_at_position(959,575)
time.sleep(random.uniform(0.07,0.11))
color23 = get_pixel_colors(95,99)
color24 = get_pixel_colors(195,99)
if color23 == (16,4,0) and color24 == (11,11,11):
send_key_press('F9') # 如果颜色符合要求,按 F10
time.sleep(random.uniform(0.6,0.9))
color11222 = get_pixel_colors(123,63)
color11242 = get_pixel_colors(210,99)
if color1222 == (8,8,8) and color1242 == (255,162,150) : # 没蓝满血加蓝
send_key_press('F8') # 如果颜色符合要求,按 F8
time.sleep(random.uniform(0.6,0.9))
color73 = get_pixel_colors(5,150) # 队友1在
color74 = get_pixel_colors(145,150) # 队友1不满血
if color73 ==(0,0,0) and color74 != (255,162,150):
click_at_position(21,166) # 点击 589,1099 的位置
time.sleep(random.uniform(0.07,0.11))
send_key_press('F2')
time.sleep(random.uniform(1.05,1.13))
click_at_position(959,575)
time.sleep(random.uniform(0.07,0.11))
color75 = get_pixel_colors(5,195) # 队友2在
color76 = get_pixel_colors(145,195) # 队友2不满血
if color75 == (0,0,0) and color76 != (255,162,150):
click_at_position(21,211) # 点击 589,1099 的位置
time.sleep(random.uniform(0.07,0.11))
send_key_press('F2')
time.sleep(random.uniform(1.05,1.13))
click_at_position(959,575)
time.sleep(random.uniform(0.07,0.11))
color77 = get_pixel_colors(5,240) # 队友3在
color78 = get_pixel_colors(145,240) # 队友3不满血
if color77 == (0,0,0) and color78 != (255,162,150):
click_at_position(22,253) # 点击 589,1099 的位置
time.sleep(random.uniform(0.07,0.11))
send_key_press('F2')
time.sleep(random.uniform(1.05,1.13))
click_at_position(959,575)
time.sleep(random.uniform(0.07,0.11))
color79 = get_pixel_colors(5,285) # 队友4在
color80 = get_pixel_colors(145,285) # 队友4不满血
if color79 == (0,0,0) and color80 != (255,162,150):
click_at_position(25,301) # 点击 589,1099 的位置
time.sleep(random.uniform(0.07,0.11))
send_key_press('F2')
time.sleep(random.uniform(1.05,1.13))
click_at_position(959,575)
time.sleep(random.uniform(0.07,0.11))
color81 = get_pixel_colors(5,330) # 队友5在
color82 = get_pixel_colors(145,330) # 队友5不满血
if color81 == (0,0,0) and color82 != (255,162,150):
click_at_position(26,345) # 点击 589,1099 的位置
time.sleep(random.uniform(0.07,0.11))
send_key_press('F2')
time.sleep(random.uniform(1.05,1.13))
click_at_position(959,575)
time.sleep(random.uniform(0.07,0.11))
color23 = get_pixel_colors(95,99)
color24 = get_pixel_colors(195,99)
if color23 == (16,4,0) and color24 == (11,11,11):
send_key_press('F10') # 如果颜色符合要求,按 F10
time.sleep(random.uniform(0.6,0.9))
color1122 = get_pixel_colors(123,63)
color1124 = get_pixel_colors(210,99)
if color122 == (8,8,8) and color124 == (255,162,150) : # 没蓝满血加蓝
send_key_press('F8') # 如果颜色符合要求,按 F8
time.sleep(random.uniform(0.6,0.9))
color121 = get_pixel_colors(136,56)
if color121 == (33,32,33): # 没血加血
send_key_press('F7') # 如果颜色符合要求,按 F7
time.sleep(random.uniform(0.6,0.9))
def qiang_xiao():# 如果肖小点开 - 点击进入副本
color7726 = get_pixel_colors(99,163)
color7727 = get_pixel_colors(166,163)
if color7726 == (255,246,0) and color7727 == (255,241,0): # 替换为实际颜色
click_at_position(82,289) # 再次点击
time.sleep(random.uniform(5,6))
def gua_ma_zei():
color2626 = get_pixel_colors(453,57) #是马贼1
color2627 = get_pixel_colors(466,56) #是马贼2
color2628 = get_pixel_colors(278,51) #有血
color2629 = get_pixel_colors(279,44) #是绿怪
for _ in range(3): # 循环3次# 如果目标是马有血且是绿怪按F2攻击。
if color2626== (205,195,196) and color2627 == (179,193,194) and color2628 == (255,162,150) and color2629 == (2,153,1): # 替换为实际颜色
send_key_press('F2')
time.sleep(random.uniform(0.07,0.11))
else:
send_key_press('F1')
time.sleep(random.uniform(0.07,0.11))
color26261 = get_pixel_colors(453,57) #是马贼1
color26271 = get_pixel_colors(466,56) #是马贼2
color26281 = get_pixel_colors(466,56) #有血
color26291 = get_pixel_colors(466,56) #不是白怪
if color26261== (205,195,196) and color26271 == (179,193,194) and color26281 == (255,162,150) and color26291 != (155,153,152): # 如果目标是马有血且不是红怪按F2攻击。
send_key_press('F2')
time.sleep(random.uniform(0.07,0.11))
else:
send_key_press('F1')
time.sleep(random.uniform(0.07,0.11))
color5 = get_pixel_colors(278,51)
color6 = get_pixel_colors(279,44)
if color5 == (255,162,150) and color6 == (155,1,1):
send_key_press('F2')
time.sleep(random.uniform(0.07,0.11))
else:
send_key_press('F1')
time.sleep(random.uniform(0.07,0.11))
def shang_jia():
color9026 = get_pixel_colors(1303,165)
if color9026 == (248,196,88): # 替换为实际颜色
time.sleep(random.uniform(0.6,0.9))
click_at_position(1069,561) # 再次点击 515,540 的位置
time.sleep(random.uniform(0.6,0.9))
def zi_dong_zu_dui():
# 如果队伍打开 - 点击同意组队
# 如果组队闪烁,如果队伍没有打开,点击组队- 点击同意组队- 点击组队
color9124 = get_pixel_colors(1341,347)
color9125 = get_pixel_colors(1241,660)
if color9124 == (248,196,88) and color9125 == (253,235,120) : # 替换为实际颜色
time.sleep(random.uniform(0.6,0.9))
click_at_position(1245,660) # 再次点击 515,540 的位置
time.sleep(random.uniform(0.6,0.9))
color9126 = get_pixel_colors(1275,1032)
color9127 = get_pixel_colors(1341,347)
if color9126 == (61,54,32) and color9127 != (248,196,88) : # 替换为实际颜色
time.sleep(random.uniform(0.6,0.9))
click_at_position(1272,1029) # 再次点击 515,540 的位置
time.sleep(random.uniform(0.6,0.9))
def run_selected_options():
global running,paused
while running:
if not paused:
for name,var in checkbutton_vars.items():
if var.get():
try:
# 根据选项名称调用相应的功能
if name == "打死换怪":
da_si_huan_guai()
elif name == "挂马贼":
gua_ma_zei()
elif name == "超出换怪":
bu_neng_gong_ji_huan_guai()
elif name == "打绿怪":
da_lv_guai()
elif name == "加状态":
jia_zhuang_tai()
elif name == "内挂":
nei_gua()
elif name == "升级":
sheng_ji()
elif name == "死亡回点":
si_wang_hui_dian()
elif name == "放技能F3":
fang_ji_neng_F3()
elif name == "珍兽出战":
zhen_shou_chu_zhan()
elif name == "放技能F4":
fang_ji_neng_F4()
elif name == "短线重连":
duan_xian_chong_lian()
elif name == "自动组队":
zi_dong_zu_dui()
elif name == "峨眉加血":
e_mei_jia_xue()
elif name == "半上架":
shang_jia()
elif name == "半抢小":
qiang_xiao()
except Exception as e:
print(f"发生错误: {e}") # 处理异常
time.sleep(0.06)
# 启动线程
thread = threading.Thread(target=run_selected_options)
thread.daemon = True
thread.start()
print("线程已启动")
# 使用 keyboard 库捕获按键
def on_key_event(event):
global paused,running
if event.name == "home": # Home 键
paused = not paused
if paused:
status_label.config(text="状态: 已暂停")
print("执行已暂停")
else:
status_label.config(text="状态: 执行中")
print("执行已恢复")
activate_window() # 恢复时激活窗口
elif event.name == "end": # End 键
running = False
status_label.config(text="状态: 已停止")
print("脚本已停止")
# 绑定键盘事件
keyboard.on_press(on_key_event)
# 状态标签
status_label = tk.Label(root, text="状态: 正常", font=("Arial", 10))
status_label.grid(row=len(checkbutton_vars) // 2 + 3, column=0, columnspan=2, pady=(5, 5)) # 增加上边距和下边距
# 加载上次保存的勾选状态
def load_checkbutton_states():
if os.path.exists("config.json"):
with open("config.json","r") as f:
states = json.load(f)
for name,var in checkbutton_vars.items():
if name in states:
var.set(states[name])
print("勾选已加载")
# 保存勾选状态的函数
def save_checkbutton_states():
states = {name: var.get() for name,var in checkbutton_vars.items()}
with open("config.json","w") as f:
json.dump(states,f)
print("勾选已保存")
# 暂停功能
def pause():
status_label.config(text="状态: 暂停")
print("已暂停")
# 在这里添加暂停的逻辑
# 恢复功能
def resume():
status_label.config(text="状态: 恢复")
print("已恢复")
# 在这里添加恢复的逻辑
# 添加复选框到窗口,改为两列显示
for i, (text, var) in enumerate(checkbutton_vars.items()):
cb = tk.Checkbutton(root, text=text, variable=var, font=("Arial", 12), bg="#f0f0f0") # 增大字体
# 计算行和列
row = i // 2
column = i % 2
cb.grid(row=row, column=column, sticky='w', padx=15, pady=10) # 增加间距
function_text = """
一. 功能键说明:
桌面和游戏分辨率1920x1080直接用
1. F1 切怪
2. F2 平推/清新
3. F3 溪山
4. F4 弹指
二. 补给功能:
1. F7 加血
2. F8 加蓝
3. F9/F10 珍兽加血
三. 特殊功能:
1. Alt + 9 彻地符录(第10个位置定位)
"""
function_label = tk.Label(root, text=function_text, justify='left', font=("Arial", 10), bg="#f0f0f0") # 增大字体
function_label.grid(row=(len(checkbutton_vars) // 2) + (len(checkbutton_vars) % 2) + 2, column=0, columnspan=2, padx=10, pady=(10, 10)) # 增加上下边距
# 加载上次保存的勾选状态
load_checkbutton_states()
# 添加保存按钮
save_button = tk.Button(root, text="保存勾选", command=save_checkbutton_states, font=("Arial", 12)) # 增大按钮字体
save_button.grid(row=len(checkbutton_vars) // 2 + 1, column=0, columnspan=1, pady=(5, 15), sticky='nse') # 靠上并居中显示
# 自动执行查找和激活窗口
activate_window()
# 运行主循环
root.mainloop()
四:安装和使用方法和上面的一样。可以自己打包安装,不分享成品是因为怕不相信。
import tkinter as tk
import pygetwindow as gw
import json
import os
import asyncio
import pyautogui
import threading
import time
import random
import win32api
import win32con
import keyboard # 新增的库
import json
import cv2
import numpy as np
from PIL import ImageGrab
# 初始化全局变量
running = True
paused = False
# 创建主窗口
root = tk.Tk()
root.title("By:打怪和拉怪")
# 假设 checkbutton_vars 是一个包含选项的字典
checkbutton_vars = {
"打死怪": tk.IntVar(),
"优先绿怪": tk.IntVar(),
"BB满血": tk.IntVar(),
}
def activate_window():#查找游戏
windows = gw.getAllTitles()
target_windows = [title for title in windows if "新天龙八部" in title]
if target_windows:
window = gw.getWindowsWithTitle(target_windows[0])[0]
window.activate()
window.maximize()
# 使用pywin32模拟按键
def send_key_press(key):
valid_keys = ['F1','F2','F3','F4','F5','F6','F7','F8','F9','F10']
if key in valid_keys:
pyautogui.press(key) # 使用 pyautogui 发送按键
def get_pixel_colors(x,y):
screenshot = pyautogui.screenshot()
return screenshot.getpixel((x,y))
def move_at_position(x, y):
pyautogui.moveTo(x, y)
# 使用 win32api 来模拟鼠标点击
def click_at_position(screen_x,screen_y):
# 使用 win32api 进行鼠标点击
win32api.SetCursorPos((screen_x,screen_y)) # 移动鼠标到指定位置
time.sleep(random.uniform(0.03,0.04))
# 模拟鼠标点击:鼠标左键按下和释放
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,0,0,0,0) # 按下鼠标左键
time.sleep(0.02) # 按下时稍作停顿
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,0,0,0,0) # 释放鼠标左键
time.sleep(random.uniform(0.03,0.04))
def da_si_huan_guai(): #打怪
bu_neng_gong_ji_huan_guai()
for _ in range(10): # 循环10次
color1 = get_pixel_colors(278,52) # 有血
color2 = get_pixel_colors(279,45) # 白怪
if color1 == (255,162,150) and color2 != (155,153,152):
send_key_press('F2')
time.sleep(random.uniform(0.07, 0.10))
else:
send_key_press('F1')
time.sleep(random.uniform(0.07, 0.10))
jia_zhuang_tai()
def da_lv_guai():
jia_zhuang_tai()
for _ in range(10): # 循环10次
color3 = get_pixel_colors(278, 52) # 有血
if color3 == (255,162,150): # 检查是否有绿怪
send_key_press('F2') # 假设F2是打绿怪的键
time.sleep(random.uniform(0.07, 0.10))
send_key_press('F1') # 默认操作
time.sleep(random.uniform(0.07, 0.10))
else:
send_key_press('F1')
time.sleep(random.uniform(0.07, 0.10))
def jia_zhuang_tai():
color28 = get_pixel_colors(95,100)
color29 = get_pixel_colors(180,100) # 珍兽加血F9闪烁
if color28 == (16,4,0) and color29 != (255,162,150):
send_key_press('F9')
time.sleep(random.uniform(0.1,0.2))
color23 = get_pixel_colors(95,100)
color24 = get_pixel_colors(196,100) # 珍兽加血F10半血
if color23 == (16,4,0) and color24 != (255,162,150):
send_key_press('F10')
time.sleep(random.uniform(0.1,0.2))
def fu_ben_zhuang_tai():
for _ in range(20): # 循环20次
color28 = get_pixel_colors(95,100)
color29 = get_pixel_colors(180,100) # 珍兽加血F9闪烁
if color28 == (16,4,0) and color29 != (255,162,150):
send_key_press('F9')
time.sleep(random.uniform(0.1,0.2))
color23 = get_pixel_colors(95,100)
color24 = get_pixel_colors(196,100) # 珍兽加血F10半血
if color23 == (16,4,0) and color24 != (255,162,150):
send_key_press('F10')
time.sleep(random.uniform(0.1,0.2))
def bu_neng_gong_ji_huan_guai():
color9 = get_pixel_colors(888,109)
color10 = get_pixel_colors(919,134)
color11 = get_pixel_colors(1012,168)
color12 = get_pixel_colors(1037,178) # 请选择目标
if color9 == (0,255,255) and color10 == (0,255,255) and color11 == (0,255,255) and color12 == (0,255,255):
send_key_press('F1')
time.sleep(random.uniform(0.07, 0.10))
color13 = get_pixel_colors(913,115)
color14 = get_pixel_colors(940,132)
color15 = get_pixel_colors(985,168)
color16 = get_pixel_colors(1006,185) # 不能攻击
if color13 == (0,255,255) and color14 == (0,255,255) and color15 == (0,255,255) and color16 == (0,255,255):
send_key_press('F1')
time.sleep(random.uniform(0.07, 0.10))
color17 = get_pixel_colors(940,111)
color18 = get_pixel_colors(966,132)
color19 = get_pixel_colors(978,167)
color20 = get_pixel_colors(987,186) # 超出范围
if color17 == (0,255,255) and color18 == (0,255,255) and color19 == (0,255,255) and color20 == (0,255,255):
send_key_press('F1')
time.sleep(random.uniform(0.07, 0.10))
def run_selected_options():
global running,paused
while running:
if not paused:
for name,var in checkbutton_vars.items():
if var.get():
try:
# 根据选项名称调用相应的功能
if name == "打死怪":
da_si_huan_guai()
elif name == "优先绿怪":
da_lv_guai()
elif name == "BB满血":
fu_ben_zhuang_tai()
except Exception as e:
print(f"发生错误: {e}") # 处理异常
time.sleep(random.uniform(0.1,0.15))
# 启动线程
thread = threading.Thread(target=run_selected_options)
thread.daemon = True
thread.start()
print("线程已启动")
# 使用 keyboard 库捕获按键
def on_key_event(event):
global paused,running
if event.name == "home": # Home 键
paused = not paused
if paused:
status_label.config(text="状态: 已暂停")
print("执行已暂停")
else:
status_label.config(text="状态: 执行中")
print("执行已恢复")
activate_window() # 恢复时激活窗口
elif event.name == "end": # End 键
running = False
status_label.config(text="状态: 已停止")
print("脚本已停止")
# 绑定键盘事件
keyboard.on_press(on_key_event)
# 状态标签
status_label = tk.Label(root, text="状态: 正常", font=("Arial", 10))
status_label.grid(row=len(checkbutton_vars) // 2 + 3, column=0, columnspan=2, pady=(5, 5)) # 增加上边距和下边距
# 加载上次保存的勾选状态
def load_checkbutton_states():
if os.path.exists("config.json"):
with open("config.json","r") as f:
states = json.load(f)
for name,var in checkbutton_vars.items():
if name in states:
var.set(states[name])
print("勾选已加载")
# 保存勾选状态的函数
def save_checkbutton_states():
states = {name: var.get() for name,var in checkbutton_vars.items()}
with open("config.json","w") as f:
json.dump(states,f)
print("勾选已保存")
# 暂停功能
def pause():
status_label.config(text="状态: 暂停")
print("已暂停")
# 在这里添加暂停的逻辑
# 恢复功能
def resume():
status_label.config(text="状态: 恢复")
print("已恢复")
# 在这里添加恢复的逻辑
# 添加复选框到窗口,改为两列显示
for i, (text, var) in enumerate(checkbutton_vars.items()):
cb = tk.Checkbutton(root, text=text, variable=var, font=("Arial", 12), bg="#f0f0f0") # 增大字体
# 计算行和列
row = i // 2
column = i % 2
cb.grid(row=row, column=column, sticky='w', padx=15, pady=10) # 增加间距
function_text = """
1、电脑游戏分辨率1920x1080
2、F1 切怪
3、F2 平推
6、F9,F10 珍兽肉
7、游戏最大化,近战不要勾拉怪。
"""
function_label = tk.Label(root, text=function_text, justify='left', font=("Arial", 10), bg="#f0f0f0") # 增大字体
function_label.grid(row=(len(checkbutton_vars) // 2) + (len(checkbutton_vars) % 2) + 2, column=0, columnspan=2, padx=10, pady=(10, 10)) # 增加上下边距
# 加载上次保存的勾选状态
load_checkbutton_states()
# 添加保存按钮
save_button = tk.Button(root, text="保存勾选", command=save_checkbutton_states, font=("Arial", 12)) # 增大按钮字体
save_button.grid(row=len(checkbutton_vars) // 2 + 1, column=0, columnspan=1, pady=(5, 15), sticky='nse') # 靠上并居中显示
# 自动执行查找和激活窗口
activate_window()
# 运行主循环
root.mainloop()
天龙怀旧游戏前台python脚本演示
一个ip只能上两个号也很容易解决,但是不建议多开搬砖,游戏只是娱乐,
五:打算玩wegame过年新区建议玩法:卡88开区玩个全3就可以了,资金充裕也最多4级,然后白嫖全4就可以了,多了就是割韭菜,小几千玩玩就行,死区也无所谓那种。。