master
abc15379 1 year ago
parent 1594f0fdad
commit 58fee164a0

@ -1,61 +1,160 @@
import hashlib
import json
import random
import time
from _md5 import md5
from time import sleep
import numpy as np
import requests
from PyQt5.QtCore import QThread, pyqtSignal
import pyautogui as p
from paddleocr import PaddleOCR
from windows.res.tools.translate import translate_text
class RegPictrue(QThread):
org_words = pyqtSignal(str)
translate_words = pyqtSignal(str)
translate_language = pyqtSignal(str)
def __init__(self, shotArea, window):
super(RegPictrue, self).__init__()
self.shotArea = shotArea
self.ocr = PaddleOCR() # 初始化OCR模型
self.ocr = PaddleOCR(use_angle_cls=False, det_db='ch_ppocr_server_v2.0_det_infer')
self.translate_window = window
self.isOpen = True
self.last_words = ''
self.language = 'zh'
self.useTrans = 1
# 百度翻译
def translate_text_baidu(self, text, from_lang, to_lang):
base_url = "https://fanyi-api.baidu.com/api/trans/vip/translate"
def make_md5(s, encoding='utf-8'):
return md5(s.encode(encoding)).hexdigest()
id = '20220121001062201'
api_key = 'LxybddF5Y966dC1BXTc5'
salt = random.randint(32768, 65536)
sign = make_md5(id + text + str(salt) + api_key)
headers = {'Content-Type': 'application/x-www-form-urlencoded'}
params = {
'q': text,
'from': from_lang,
'to': to_lang,
'appid': id,
'salt': salt,
'sign': sign,
}
response = requests.post(base_url, params=params, headers=headers)
result = response.json()
if 'trans_result' in result:
translated_text = result['trans_result'][0]['dst']
return translated_text
else:
return '翻译失败'
# 金山翻译
def translate_text_jinshan(self, text, from_lang, to_lang):
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) '
'Chrome/107.0.0.0 Safari/537.36'
}
data = {
'from': from_lang,
'to': to_lang,
'q': text
}
sign = (hashlib.md5(("6key_web_fanyiifanyiweb8hc9s98e" + text).encode('utf-8')).hexdigest())[0:16]
url = 'http://ifanyi.iciba.com/index.php?c=trans&m=fy&client=6&auth_user=key_web_fanyi&sign=' + sign
res = requests.post(url=url, headers=headers, data=data).json()
if 'content' in res:
translated_text = res['content']['out']
return translated_text
else:
return '翻译失败'
def translate_text_xiaoniu(self, text, from_lang, to_lang):
url = 'http://api.niutrans.com/NiuTransServer/translation?'
data = {"from": from_lang, "to": to_lang, "apikey": 'c515a5ac919680e404af33a9b461179c', "src_text": text}
res = requests.post(url, data=data)
res_dict = json.loads(res.text)
if "tgt_text" in res_dict:
result = res_dict['tgt_text']
else:
result = res
return result
def run(self):
# 获取到框中图片的文本
while self.isOpen:
screenshot = p.screenshot(region=(self.shotArea['left'], self.shotArea['top'],
self.shotArea['width'], self.shotArea['height']))
screenshot_np = np.array(screenshot.convert('RGB'))[:, :, ::-1] # 将Pillow图像对象转换为np.ndarray类型
screenshot_np = np.array(screenshot) # 将Pillow图像对象转换为np.ndarray类型
result = self.ocr.ocr(screenshot_np, cls=False)
# print(result)
# 翻译将res每一行翻译出来的文本加到orgword中
orgwords = ''
for idx in result:
res = idx[1][0]
orgwords += res
if idx is None:
continue
else:
# for idx2 in idx:
res = ''.join(idx[1][0])
# print(res, "\n")
orgwords += res
self.org_words.emit(orgwords)
# 设置源语言和目标语言
from_language = 'auto' # 自动检测语言
to_language = 'zh' # 翻译成中文
to_language = self.getLanguage() # 翻译成各种语言
if orgwords != self.last_words:
# 记录代码开始执行的时间
start_time = time.time()
print(orgwords)
# # 记录代码开始执行的时间
# start_time = time.time()
# 调用翻译函数并输出结果
translated_text = translate_text(orgwords, from_language, to_language)
if translated_text:
self.translate_words.emit(translated_text)
if self.useTrans == 0:
translated_text = self.translate_text_baidu('orgwords', from_language, to_language)
if translated_text == '翻译失败':
# self.useTrans += 1
pass
elif self.useTrans == 1:
translated_text = self.translate_text_jinshan(orgwords, from_language, to_language)
if translated_text == '翻译失败':
self.useTrans += 1
elif self.useTrans == 2:
translated_text = self.translate_text_xiaoniu(orgwords, from_language, to_language)
if translated_text == '翻译失败':
self.useTrans = 1
else:
self.translate_words.emit("翻译失败。")
translated_text = '翻译失败'
self.useTrans = 1
self.translate_words.emit(translated_text)
# 记录代码结束执行的时间
end_time = time.time()
# 计算代码的运行时间(以秒为单位)
execution_time = end_time - start_time
print(f"代码执行时间:{execution_time}")
# self.translate_words.emit("翻译失败。")
# # 记录代码结束执行的时间
# end_time = time.time()
# # 计算代码的运行时间(以秒为单位)
# execution_time = end_time - start_time
# print(f"代码执行时间:{execution_time}秒")
self.last_words = orgwords
sleep(0.1)
def setLanguage(self, language='zh'):
self.language = language
def getLanguage(self):
return self.language

@ -1,9 +1,6 @@
import pyautogui
import cv2
import numpy as np
from PIL.Image import Image
from paddleocr import PaddleOCR
from paddleocr.tools.infer.utility import draw_ocr
class SetShotArea():
@ -18,7 +15,7 @@ class SetShotArea():
self.capture = pyautogui.screenshot()
# 将截图转换为OpenCV格式
self.capture = np.array(self.capture.convert('RGB'))[:, :, ::-1]
self.capture = np.array(self.capture)
self.capture = cv2.cvtColor(self.capture, cv2.COLOR_RGB2BGR)
# 回调函数,用于处理鼠标事件
@ -53,7 +50,8 @@ class SetShotArea():
cv2.imshow("Capture", self.capture)
key = cv2.waitKey(1) & 0xFF
# 当用户按下'Enter'键时截取矩形区域并保存为文件
# 当用户按下'Enter'键时截取矩形区域并保存为文件,'Esc'为退出截屏模式
if key == 13:
if len(rect_coordinates) == 2:
x1, y1 = rect_coordinates[0]
@ -61,9 +59,18 @@ class SetShotArea():
shotArea = {'left': min(x1, x2), 'top': min(y1, y2), 'width': max(x1, x2) - min(x1, x2),
'height': max(y1, y2) - min(y1, y2)}
print(shotArea)
cv2.destroyAllWindows()
return shotArea
break
else:
print("请先绘制矩形区域再按下'Enter'键进行截图!")
print("请选择识别区域")
elif key == 27:
cv2.destroyAllWindows()
break
elif key == 32:
#按下空格,使用默认区域
print("使用默认区域翻译")
shotArea = {'left': 116, 'top': 792, 'width': 1325, 'height': 146}
cv2.destroyAllWindows()
return shotArea

@ -0,0 +1,185 @@
import sqlite3
import os
current_path = os.path.dirname(os.path.abspath(__file__))
print(current_path)
DB_FOLDER = current_path
class DatabaseHandler:
def __init__(self, database):
self.database = os.path.join(DB_FOLDER, database)
self.conn = None
self.cur = None
def connect(self):
self.conn = sqlite3.connect(self.database)
self.cur = self.conn.cursor()
def create_table(self, table_name):
self.cur.execute(f"CREATE TABLE IF NOT EXISTS {table_name} (pid INTEGER PRIMARY KEY AUTOINCREMENT, id INTEGER, path VARCHAR, xOffset INTEGER, yOffset INTEGER, pOffsetX INTEGER, pOffsetY INTEGER, time INTEGER, rgb VARCHAR);")
self.conn.commit()
print('创建成功')
def insert_data(self, table_name, id, path, xOffset, yOffset, pOffsetX, pOffsetY, time, rgb):
try:
self.cur.execute(f"SELECT MAX(pid) FROM {table_name}")
max_pid = self.cur.fetchone()[0]
if max_pid is not None:
pid = max_pid + 1
else:
pid = 1
self.cur.execute(
f"INSERT INTO {table_name} (pid, id, path, xOffset, yOffset, pOffsetX, pOffsetY, time, rgb) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)",
(pid, id, path, xOffset, yOffset, pOffsetX, pOffsetY, time, rgb))
self.conn.commit()
print("数据插入成功")
except sqlite3.Error as e:
print(f"插入数据失败: {str(e)}")
def insert_pidData(self, table_name, id, path, xOffset, yOffset, pOffsetX, pOffsetY, time, rgb, pid=None):
try:
self.cur.execute(f"SELECT MAX(pid) FROM {table_name}")
max_pid = self.cur.fetchone()[0]
if max_pid is not None:
if pid > max_pid:
pid = max_pid + 1
self.cur.execute(
f"INSERT INTO {table_name} (pid, id, path, xOffset, yOffset, pOffsetX, pOffsetY, time, rgb) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)",
(pid, id, path, xOffset, yOffset, pOffsetX, pOffsetY, time, rgb))
self.conn.commit()
print("数据插入成功")
else:
for i in range(max_pid, pid - 1, -1):
self.cur.execute(
f"UPDATE {table_name} SET pid = ? WHERE pid = ?",
(i + 1, i))
self.cur.execute(
f"INSERT INTO {table_name} (pid, id, path, xOffset, yOffset, pOffsetX, pOffsetY, time, rgb) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)",
(pid, id, path, xOffset, yOffset, pOffsetX, pOffsetY, time, rgb))
self.conn.commit()
print("数据插入成功")
else:
pid = 1
self.cur.execute(
f"INSERT INTO {table_name} (pid, id, path, xOffset, yOffset, pOffsetX, pOffsetY, time, rgb) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)",
(pid, id, path, xOffset, yOffset, pOffsetX, pOffsetY, time, rgb))
self.conn.commit()
print("数据插入成功")
except sqlite3.Error as e:
print(f"插入数据失败: {str(e)}")
def execute_query(self, table_name, pid=None):
try:
if pid is None:
self.cur.execute(f"SELECT pid, * FROM {table_name}")
rows = self.cur.fetchall()
for row in rows:
pid = row[0] # 第0列是pid
data = row[1:] # 后续列为数据
print(f"pid: {pid}, data: {data}")
return rows # 返回所有行的结果集
else:
self.cur.execute(f"SELECT * FROM {table_name} WHERE pid = ?", (pid,))
row = self.cur.fetchone()
if row:
print(f"Row with pid {pid}: {row[1:]}")
else:
print(f"Row with pid {pid} not found")
return row[1:]
except Exception as e:
print(f"Error executing query on table {table_name}: {str(e)}")
def delete_table(self, table_name):
try:
self.cur.execute(f"DROP TABLE IF EXISTS {table_name}")
self.conn.commit()
print(f"Table {table_name} deleted")
except Exception as e:
print(f"Error deleting table {table_name}: {str(e)}")
def delete_row(self, table_name, pid):
try:
# 1. 获取删除行的pid和其后面的所有pid
self.cur.execute(f"SELECT pid FROM {table_name} WHERE pid >= ?", (pid,))
rows_to_update = self.cur.fetchall()
# 2. 删除指定行
self.cur.execute(f"SELECT path FROM {table_name} WHERE pid = ?", (pid,))
path = self.cur.fetchall()
self.cur.execute(f"DELETE FROM {table_name} WHERE pid = ?", (pid,))
# 3. 更新后面行的pid
for row in rows_to_update:
new_pid = row[0] - 1
self.cur.execute(f"UPDATE {table_name} SET pid = ? WHERE pid = ?", (new_pid, row[0]))
self.conn.commit()
print(f"Row with pid {pid} deleted from {table_name}")
return path
except Exception as e:
print(f"An error occurred: {e}")
return None
def get_max_pid(self, table_name):
try:
self.cur.execute(f"SELECT MAX(pid) FROM {table_name}")
max_pid = self.cur.fetchone()[0]
if max_pid is not None:
return max_pid
else:
return 0
except sqlite3.Error as e:
print(f"获取最大 pid 失败: {str(e)}")
return 0
def close(self):
self.conn.close()
# 示例用法
class DatabaseDatum:
def __init__(self, *args):
self.id = args[0]
self.path = args[1]
self.xOffset = args[2]
self.yOffset = args[3]
self.pOffsetX = args[4]
self.pOffsetY = args[5]
self.time = args[6]
self.rgb = args[7]
'''def get_path_by_pid(self, tablename, pid):
db = DatabaseHandler(database='test2.sqlite3')
db.connect()
query = f"SELECT path FROM {tablename} WHERE pid = ?;"
db.cur.execute(query, (pid,))
result = db.cur.fetchone()
db.close()
if result:
self.path = result[0]
else:
self.path = None
return self.path
'''
# 创建一个DatabaseDatum对象
# 调用get_path_by_pid
#(datum.get_path_by_pid('rule10',1))
# db = DatabaseHandler(database='test2.sqlite3')
# db.connect()
# path = db.delete_row('rule13', 3)
#
# if path and len(path) > 0:
# result = path[0][0]
# print(result)
# else:
# print("No path found")
#
# db.close()
#

@ -1,94 +0,0 @@
import psycopg2
from psycopg2 import errors
class DatabaseHandler:
def __init__(self, database, user, password, host, port):
self.database = database
self.user = user
self.password = password
self.host = host
self.port = port
self.conn = None
self.cur = None
def connect(self):
self.conn = psycopg2.connect(database=self.database,
user=self.user,
password=self.password,
host=self.host,
port=self.port)
self.cur = self.conn.cursor()
def create_table(self, table_name):
self.cur.execute(
"SELECT EXISTS(SELECT 1 FROM information_schema.tables WHERE table_name='" + table_name + "');")
table_exists = self.cur.fetchone()[0]
if table_exists:
print("表已存在")
else:
try:
self.cur.execute(f"CREATE SEQUENCE {table_name}_pid_seq START 1;")
self.cur.execute(
f"CREATE TABLE {table_name} (pid INTEGER DEFAULT nextval('{table_name}_pid_seq'), id INTEGER, path VARCHAR, xOffset INTEGER, yOffset INTEGER, pOffsetX INTEGER, pOffsetY INTEGER, time INTEGER, rgb VARCHAR);")
self.conn.commit()
print("操作成功")
except errors.DuplicateTable:
print("表已存在")
def insert_data(self, table_name, id, path, xOffset, yOffset, pOffsetX, pOffsetY, time, rgb):
try:
self.cur.execute(
f"INSERT INTO {table_name} (id, path, xOffset, yOffset, pOffsetX, pOffsetY, time, rgb) VALUES ({id}, '{path}', {xOffset}, {yOffset}, {pOffsetX}, {pOffsetY}, {time}, '{rgb}')")
self.conn.commit()
print("数据插入成功")
except errors.ForeignKeyViolation:
print("插入数据失败")
def execute_query(self, table_name):
self.cur.execute("SELECT * FROM " + table_name)
rows = self.cur.fetchall()
for row in rows:
print(row)
def close(self):
self.conn.close()
#
# # 示例用法
# db = DatabaseHandler(database='gamerule', user='postgres', password='123456', host='localhost', port='5432')
# db.connect()
# db.create_table('rule11')
# db.insert_data('rule11', 9, '../pictures/terminal_photo.png', 10, 20, 30, 40, 12345, '255,0,0')
# db.execute_query('rule11')
# db.close()
class DatabaseDatum:
def __init__(self, tablename=None, id=None, path=None, xOffset=None, yOffset=None, pOffsetX=None, pOffsetY=None,
time=None, rgb=None):
self.tablename = tablename
self.id = id
self.path = path
self.xOffset = xOffset
self.yOffset = yOffset
self.pOffsetX = pOffsetX
self.pOffsetY = pOffsetY
self.time = time
self.rgb = rgb
def get_path_by_pid(self, tablename, pid):
db = DatabaseHandler(database='gamerule', user='postgres', password='123456', host='localhost', port='5432')
db.connect()
query = f"SELECT path FROM {tablename} WHERE pid = {pid};"
db.cur.execute(query)
result = db.cur.fetchone()
db.close()
if result:
self.path = result[0]
else:
self.path = None
return self.path

@ -0,0 +1,227 @@
import sqlite3
import os
current_path = os.path.dirname(os.path.abspath(__file__))
print(current_path)
DB_FOLDER = current_path
class DatabaseHandler:
def __init__(self, database):
self.database = os.path.join(DB_FOLDER, database)
self.conn = None
self.cur = None
def connect(self):
self.conn = sqlite3.connect(self.database)
self.cur = self.conn.cursor()
def create_table(self, table_name):
self.cur.execute(
f"CREATE TABLE IF NOT EXISTS {table_name} (pid INTEGER PRIMARY KEY AUTOINCREMENT, id INTEGER, path VARCHAR, xOffset INTEGER, yOffset INTEGER, pOffsetX INTEGER, pOffsetY INTEGER, time INTEGER, rgb VARCHAR);")
self.conn.commit()
print('创建成功')
def insert_data(self, table_name, id, path, xOffset, yOffset, pOffsetX, pOffsetY, time, rgb):
try:
self.cur.execute(f"SELECT MAX(pid) FROM {table_name}")
max_pid = self.cur.fetchone()[0]
if max_pid is not None:
pid = max_pid + 1
else:
pid = 1
self.cur.execute(
f"INSERT INTO {table_name} (pid, id, path, xOffset, yOffset, pOffsetX, pOffsetY, time, rgb) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)",
(pid, id, path, xOffset, yOffset, pOffsetX, pOffsetY, time, rgb))
self.conn.commit()
print("数据插入成功")
except sqlite3.Error as e:
print(f"插入数据失败: {str(e)}")
def insert_pidData(self, table_name, id, path, xOffset, yOffset, pOffsetX, pOffsetY, time, rgb, pid=None):
try:
self.cur.execute(f"SELECT MAX(pid) FROM {table_name}")
max_pid = self.cur.fetchone()[0]
if max_pid is not None:
if pid > max_pid:
pid = max_pid + 1
self.cur.execute(
f"INSERT INTO {table_name} (pid, id, path, xOffset, yOffset, pOffsetX, pOffsetY, time, rgb) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)",
(pid, id, path, xOffset, yOffset, pOffsetX, pOffsetY, time, rgb))
self.conn.commit()
print("数据插入成功")
else:
for i in range(max_pid, pid - 1, -1):
self.cur.execute(
f"UPDATE {table_name} SET pid = ? WHERE pid = ?",
(i + 1, i))
self.cur.execute(
f"INSERT INTO {table_name} (pid, id, path, xOffset, yOffset, pOffsetX, pOffsetY, time, rgb) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)",
(pid, id, path, xOffset, yOffset, pOffsetX, pOffsetY, time, rgb))
self.conn.commit()
print("数据插入成功")
else:
pid = 1
self.cur.execute(
f"INSERT INTO {table_name} (pid, id, path, xOffset, yOffset, pOffsetX, pOffsetY, time, rgb) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)",
(pid, id, path, xOffset, yOffset, pOffsetX, pOffsetY, time, rgb))
self.conn.commit()
print("数据插入成功")
except sqlite3.Error as e:
print(f"插入数据失败: {str(e)}")
def execute_query(self, table_name, pid=None):
try:
if pid is None:
self.cur.execute(f"SELECT pid, * FROM {table_name}")
rows = self.cur.fetchall()
for row in rows:
pid = row[0] # 第0列是pid
data = row[1:] # 后续列为数据
print(f"pid: {pid}, data: {data}")
return rows # 返回所有行的结果集
else:
self.cur.execute(f"SELECT * FROM {table_name} WHERE pid = ?", (pid,))
row = self.cur.fetchone()
if row:
print(f"Row with pid {pid}: {row[1:]}")
else:
print(f"Row with pid {pid} not found")
return row[1:]
except Exception as e:
print(f"Error executing query on table {table_name}: {str(e)}")
def delete_table(self, table_name):
try:
self.cur.execute(f"DROP TABLE IF EXISTS {table_name}")
self.conn.commit()
print(f"Table {table_name} deleted")
except Exception as e:
print(f"Error deleting table {table_name}: {str(e)}")
def delete_row(self, table_name, pid):
try:
# 1. 获取删除行的pid和其后面的所有pid
self.cur.execute(f"SELECT pid FROM {table_name} WHERE pid >= ?", (pid,))
rows_to_update = self.cur.fetchall()
# 2. 删除指定行
self.cur.execute(f"SELECT path FROM {table_name} WHERE pid = ?", (pid,))
path = self.cur.fetchall()
self.cur.execute(f"DELETE FROM {table_name} WHERE pid = ?", (pid,))
# 3. 更新后面行的pid
for row in rows_to_update:
new_pid = row[0] - 1
self.cur.execute(f"UPDATE {table_name} SET pid = ? WHERE pid = ?", (new_pid, row[0]))
self.conn.commit()
print(f"Row with pid {pid} deleted from {table_name}")
return path
except Exception as e:
print(f"An error occurred: {e}")
return None
def get_max_pid(self, table_name):
try:
self.cur.execute(f"SELECT MAX(pid) FROM {table_name}")
max_pid = self.cur.fetchone()[0]
if max_pid is not None:
return max_pid
else:
return 0
except sqlite3.Error as e:
print(f"获取最大 pid 失败: {str(e)}")
return 0
@staticmethod
def init_db():
db = DatabaseHandler(database='test2.sqlite3')
db.connect()
db.cur.execute(f"SELECT pid, * FROM userConcreteRule")
rows = db.cur.fetchall()
# 检查结果
if rows:
print("表有内容")
else:
print("表没内容")
db.create_table('userGeneralRule')
db.create_table('userConcreteRule')
db.insert_data('userConcreteRule', 0, '返回终端界面', 0, 0, 0, 0, 0, 0)
db.insert_data('userConcreteRule', 0, '找到目标关卡', 0, 0, 0, 0, 0, 0)
db.insert_data('userConcreteRule', 0, '找到目标章节', 0, 0, 0, 0, 0, 0)
db.insert_data('userConcreteRule', 0, '战斗', 0, 0, 0, 0, 0, 0)
db.insert_data('userConcreteRule', 0, '回到基建界面', 0, 0, 0, 0, 0, 0)
db.insert_data('userConcreteRule', 0, '进入基建界面', 0, 0, 0, 0, 0, 0)
db.insert_data('userConcreteRule', 0, '获得奖励', 0, 0, 0, 0, 0, 0)
db.insert_data('userConcreteRule', 0, '进入基建总览', 0, 0, 0, 0, 0, 0)
db.insert_data('userConcreteRule', 0, '改变总览宿舍干员', 0, 0, 0, 0, 0, 0)
db.insert_data('userConcreteRule', 0, '改变发电站干员', 0, 0, 0, 0, 0, 0)
db.insert_data('userConcreteRule', 0, '改变总览工作室干员', 0, 0, 0, 0, 0, 0)
db.insert_data('userConcreteRule', 0, '进入交易站', 0, 0, 0, 0, 0, 0)
db.insert_data('userConcreteRule', 0, '进入生产站', 0, 0, 0, 0, 0, 0)
db.insert_data('userConcreteRule', 0, '到下一个工作室', 0, 0, 0, 0, 0, 0)
db.insert_data('userConcreteRule', 0, '改变当前工作站干员', 0, 0, 0, 0, 0, 0)
db.insert_data('userConcreteRule', 0, '获取信用点', 0, 0, 0, 0, 0, 0)
db.insert_data('userConcreteRule', 0, '消耗信用点', 0, 0, 0, 0, 0, 0)
db.insert_data('userConcreteRule', 0, '获得日常奖励', 0, 0, 0, 0, 0, 0)
db.insert_data('userConcreteRule', 0, '进入招募界面', 0, 0, 0, 0, 0, 0)
db.insert_data('userConcreteRule', 0, '公开招募所有', 0, 0, 0, 0, 0, 0)
db.insert_data('userConcreteRule', 0, '公开招募一个', 0, 0, 0, 0, 0, 0)
db.insert_data('userConcreteRule', 0, '使用加急凭证', 0, 0, 0, 0, 0, 0)
db.close()
def close(self):
self.conn.close()
# 示例用法
class DatabaseDatum:
def __init__(self, *args):
self.id = args[0]
self.path = args[1]
self.xOffset = args[2]
self.yOffset = args[3]
self.pOffsetX = args[4]
self.pOffsetY = args[5]
self.time = args[6]
self.rgb = args[7]
'''def get_path_by_pid(self, tablename, pid):
db = DatabaseHandler(database='test2.sqlite3')
db.connect()
query = f"SELECT path FROM {tablename} WHERE pid = ?;"
db.cur.execute(query, (pid,))
result = db.cur.fetchone()
db.close()
if result:
self.path = result[0]
else:
self.path = None
return self.path
'''
# 创建一个DatabaseDatum对象
# 调用get_path_by_pid
# (datum.get_path_by_pid('rule10',1))
# db = DatabaseHandler(database='test2.sqlite3')
# db.connect()
# path = db.delete_row('rule13', 3)
#
# if path and len(path) > 0:
# result = path[0][0]
# print(result)
# else:
# print("No path found")
#
# db.close()
#

@ -0,0 +1,46 @@
import cv2
import numpy as np
import pyautogui as p
from PIL.Image import Image
from windows.res.tools.deal_picture import DealPicture
from windows.res.tools.recognise_words import Recognise_word
class end_condition:
@staticmethod
def area_changed(last_photo, current_photo):
last = last_photo
current = current_photo
# 将元组转换为字典
if isinstance(last, Image):
last_np = np.array(last.convert('RGB'))[:, :, ::-1]
else:
last_np = last_photo
if isinstance(current, Image):
current_np = [np.array(current.convert('RGB'))[:, :, ::-1]]
else:
current_np = [current]
changed = DealPicture.mapping_any_photo(last_np, current_np, 0.98)
if changed:
return False
else:
return True
@staticmethod
def find_photo(photo_adrees):
photo = cv2.imread(photo_adrees)
if DealPicture.find_photo_center(photo) is not None:
return True
return False
@staticmethod
def find_word(word):
shot_photo = p.screenshot()
words_inf = Recognise_word.recognise_word(shot_photo)
position = Recognise_word.find_word_positon(word, words_inf)
if position is not None:
return True
return False

@ -1,90 +1,36 @@
import time
import cv2
import pyautogui as p
from windows.res.tools.deal_picture import DealPicture
from windows.res.tools.recognise_words import Recognise_word
class operation:
@staticmethod
def mouse_to_lefttop():
p.moveTo(10, 10, duration=0.3)
def find_word_position(word):
shot_photo = p.screenshot()
words_inf = Recognise_word.recognise_word(shot_photo)
position = Recognise_word.find_word_positon(word, words_inf)
if position is not None:
return position
return None
@staticmethod
def click_position_once(position):
# 检查变量是否为元组
if isinstance(position, tuple):
# 将元组转换为字典
position_dict = {
'left': position[0],
'top': position[1],
'width': position[2],
'height': position[3]
}
else:
position_dict = position
x, y = (position_dict['left']+position_dict['width']/2), (position_dict['top']+position_dict['height']/2)
p.click(x, y)
time.sleep(0.1)
operation.mouse_to_lefttop()
def find_photo_position(photo_str):
photo = cv2.imread(photo_str)
position = DealPicture.find_photo_position(photo)
if position is not None:
return position
return None
@staticmethod
def click_position_util(position, stop_function):
count = 0
x, y = (position['left'] + position['width'] / 2), (position['top'] + position['height'] / 2)
p.click(x, y)
time.sleep(0.1)
operation.mouse_to_lefttop()
while stop_function() is False or stop_function() is None:
x, y = (position['left'] + position['width'] / 2), (position['top'] + position['height'] / 2)
p.click(x, y)
time.sleep(0.1)
count += 1
if count >= 6:
break
time.sleep(0.1)
def position_translate(x, y):
@staticmethod
def click_once(photo, pOffsetX=None, pOffsetY=None):
poffsetx = 0
poffsety = 0
if pOffsetX:
poffsetx = pOffsetX
if pOffsetY:
poffsety = pOffsetY
positions = p.locateCenterOnScreen(photo, confidence=0.8)
x, y = positions.x + poffsetx, positions.y +poffsety
p.click(x, y)
time.sleep(0.1)
operation.mouse_to_lefttop()
@staticmethod
def click_util(click_photo, stop_function, pOffsetX=None, pOffsetY=None):
poffsetx = 0
poffsety = 0
if pOffsetX:
poffsetx = pOffsetX
if pOffsetY:
poffsety = pOffsetY
count = 0
positions = DealPicture.find_photo_center(click_photo)
if positions:
x, y = positions.x + poffsetx, positions.y + poffsety
p.click(x, y)
operation.mouse_to_lefttop()
while stop_function() is False or stop_function() is None:
positions = DealPicture.find_photo_center(click_photo)
if positions:
x, y = positions.x + poffsetx, positions.y + poffsety
p.click(x, y)
else:
count += 1
if count == 20:
break
time.sleep(0.1)
position = {'left': x, 'top': y, 'height': 0, 'width': 0}
return position
@staticmethod
def drag_once(drop_position, xOffset=None, yOffset=None, pOffsetX=None, pOffsetY=None):
@ -101,10 +47,11 @@ class operation:
if pOffsetY:
poffsety = pOffsetY
positions = p.locateCenterOnScreen(drop_position, confidence=0.8)
position_x = drop_position['left'] + drop_position['width'] / 2
position_y = drop_position['top'] + drop_position['height'] / 2
if positions:
x, y = positions.x, positions.y
if True:
x, y = position_x, position_y
# 长按鼠标左键
p.mouseDown(x=x + poffsetx, y=y + poffsety, button='left')
@ -117,37 +64,100 @@ class operation:
time.sleep(0.3)
@staticmethod
def drag_util(drop_position, stop_function, xOffset=None, yOffset=None, pOffsetX=None, pOffsetY=None):
count = 0
offsetx = 0
offsety = 0
poffsetx = 0
poffsety = 0
if xOffset:
offsetx = xOffset
if yOffset:
offsety = yOffset
if pOffsetX:
poffsetx = pOffsetX
if pOffsetY:
poffsety = pOffsetY
while stop_function() is False:
positions = DealPicture.find_photo_center(drop_position, 3)
if positions:
x, y = positions.x, positions.y
# 长按鼠标左键
p.mouseDown(x=x + poffsetx, y=y + poffsety, button='left')
# 向上移动鼠标这里移动了100像素可以根据需要调整
p.moveRel(offsetx, offsety, duration=1)
# 延迟一段时间
time.sleep(0.2)
# 松开鼠标左键
p.mouseUp(x=x + poffsetx + offsetx, y=y + poffsety + offsety, button='left')
time.sleep(0.3)
else:
count += 1
if count == 10:
break
def left_drag(position, distence, xoffset=None, yoffset=None):
if position is None:
print('位置为空')
return False
if xoffset is not None:
x = xoffset
else:
x = 0
if yoffset is not None:
y = yoffset
else:
y = 0
operation.drag_once(position, (-distence), 0, x, y)
@staticmethod
def right_drag(position, distence, xoffset=None, yoffset=None):
if position is None:
print('位置为空')
return False
if xoffset is not None:
x = xoffset
else:
x = 0
if yoffset is not None:
y = yoffset
else:
y = 0
operation.drag_once(position, distence, 0, x, y)
@staticmethod
def up_drag(position, distence, xoffset=None, yoffset=None):
if position is None:
print('位置为空')
return False
if xoffset is not None:
x = xoffset
else:
x = 0
if yoffset is not None:
y = yoffset
else:
y = 0
operation.drag_once(position, 0, (-distence), x, y)
@staticmethod
def down_drag(position, distence, xoffset=None, yoffset=None):
if position is None:
print('位置为空')
return False
if xoffset is not None:
x = xoffset
else:
x = 0
if yoffset is not None:
y = yoffset
else:
y = 0
operation.drag_once(position, 0, distence, x, y)
@staticmethod
def click_long(position, xoffset=None, yoffset=None):
if position is None:
print('位置为空')
return False
if xoffset is not None:
x = xoffset
else:
x = 0
if yoffset is not None:
y = yoffset
else:
y = 0
# 长按鼠标左键
p.mouseDown(x=x + position['left'] + position['width'] / 2,
y=y + position['top'] + position['height'] / 2,
button='left')
# 向上移动鼠标这里移动了100像素可以根据需要调整
p.moveRel(x, y, duration=1)
# 延迟一段时间
time.sleep(0.2)
# 松开鼠标左键
p.mouseUp(x=x + position['left'] + position['width'] / 2,
y=y + position['top'] + position['height'] / 2,
button='left')
time.sleep(0.3)
@staticmethod
def keyin(words):
time.sleep(2)
# 使用typewrite函数输入符号
p.typewrite(words)
# 等待一段时间,然后关闭窗口
time.sleep(2)

@ -0,0 +1,173 @@
import time
import pyautogui as p
from windows.res.tools.deal_picture import DealPicture
class operation_first:
@staticmethod
def mouse_to_lefttop():
p.moveTo(10, 10, duration=0.3)
@staticmethod
def click_position_once(position):
# 检查变量是否为元组
if isinstance(position, tuple):
# 将元组转换为字典
position_dict = {
'left': position[0],
'top': position[1],
'width': position[2],
'height': position[3]
}
else:
position_dict = position
x, y = (position_dict['left']+position_dict['width']/2), (position_dict['top']+position_dict['height']/2)
p.click(x, y)
time.sleep(0.1)
operation_first.mouse_to_lefttop()
@staticmethod
def click_position_util(position, stop_function, click_limit1=None):
count = 0
x, y = (position['left'] + position['width'] / 2), (position['top'] + position['height'] / 2)
p.click(x, y)
time.sleep(0.1)
operation_first.mouse_to_lefttop()
stop = stop_function()
if click_limit1 is not None:
click_limit = click_limit1
else:
click_limit = 10
while stop is False or stop is None:
x, y = (position['left'] + position['width'] / 2), (position['top'] + position['height'] / 2)
p.click(x, y)
operation_first.mouse_to_lefttop()
time.sleep(0.1)
count += 1
if count >= click_limit:
break
stop = stop_function()
time.sleep(0.1)
@staticmethod
def click_once(photo, pOffsetX=None, pOffsetY=None):
poffsetx = 0
poffsety = 0
if pOffsetX:
poffsetx = pOffsetX
if pOffsetY:
poffsety = pOffsetY
positions = p.locateCenterOnScreen(photo, confidence=0.8)
x, y = positions.x + poffsetx, positions.y +poffsety
p.click(x, y)
time.sleep(0.1)
operation_first.mouse_to_lefttop()
@staticmethod
def click_util(click_photo, stop_function, pOffsetX=None, pOffsetY=None, click_limit1=None):
poffsetx = 0
poffsety = 0
if pOffsetX:
poffsetx = pOffsetX
if pOffsetY:
poffsety = pOffsetY
if click_limit1 is not None:
click_limit = click_limit1
else:
click_limit = 10
count = 0
positions = DealPicture.find_photo_center(click_photo)
if positions:
x, y = positions.x + poffsetx, positions.y + poffsety
p.click(x, y)
operation_first.mouse_to_lefttop()
stop = stop_function()
while stop is False or stop is None:
positions = DealPicture.find_photo_center(click_photo)
if positions:
x, y = positions.x + poffsetx, positions.y + poffsety
p.click(x, y)
operation_first.mouse_to_lefttop()
count += 1
if count >= click_limit:
break
stop = stop_function()
time.sleep(0.1)
@staticmethod
def drag_once(drop_position, xOffset=None, yOffset=None, pOffsetX=None, pOffsetY=None):
offsetx = 0
offsety = 0
poffsetx = 0
poffsety = 0
if xOffset:
offsetx = xOffset
if yOffset:
offsety = yOffset
if pOffsetX:
poffsetx = pOffsetX
if pOffsetY:
poffsety = pOffsetY
positions = p.locateCenterOnScreen(drop_position, confidence=0.8)
if positions:
x, y = positions.x, positions.y
# 长按鼠标左键
p.mouseDown(x=x + poffsetx, y=y + poffsety, button='left')
# 向上移动鼠标这里移动了100像素可以根据需要调整
p.moveRel(offsetx, offsety, duration=1)
# 延迟一段时间
time.sleep(0.2)
# 松开鼠标左键
p.mouseUp(x=x + poffsetx + offsetx, y=y + poffsety + offsety, button='left')
time.sleep(0.3)
@staticmethod
def drag_util(drop_position, stop_function, xOffset=None, yOffset=None, pOffsetX=None, pOffsetY=None, click_limit1=None):
count = 0
offsetx = 0
offsety = 0
poffsetx = 0
poffsety = 0
if xOffset:
offsetx = xOffset
if yOffset:
offsety = yOffset
if pOffsetX:
poffsetx = pOffsetX
if pOffsetY:
poffsety = pOffsetY
if click_limit1 is not None:
click_limit = click_limit1
else:
click_limit = 10
stop = stop_function()
while stop is False or stop is None:
positions = DealPicture.find_photo_center(drop_position, 3)
if positions:
x, y = positions.x, positions.y
# 长按鼠标左键
p.mouseDown(x=x + poffsetx, y=y + poffsety, button='left')
# 向上移动鼠标这里移动了100像素可以根据需要调整
p.moveRel(offsetx, offsety, duration=1)
# 延迟一段时间
time.sleep(0.2)
# 松开鼠标左键
p.mouseUp(x=x + poffsetx + offsetx, y=y + poffsety + offsety, button='left')
time.sleep(0.1)
operation_first.mouse_to_lefttop()
count += 1
if count >= click_limit:
break
stop = stop_function()
time.sleep(0.3)

@ -1,8 +1,239 @@
class Priority:
pubilc_recruit = [
[['高级资深干员'], 6],
[['先锋干员', '控场'], 5],
[['费用恢复', '控场'], 5],
[['近战位', '控场'], 5],
[['先锋干员', '支援'], 5],
[['费用恢复', '支援'], 5],
[['先锋干员', '治疗'], 4],
[['费用恢复', '治疗'], 4],
[['近卫干员', '群攻', '输出'], 5],
[['近卫干员', '防护', '输出'], 5],
[['近战位', '防护', '输出'], 5],
[['群攻', '输出'], 5],
[['近卫干员', '防护'], 5],
[['输出', '防护'], 5],
[['近卫干员', '爆发'], 4],
[['近战位', '爆发'], 4],
[['爆发'], 4],
[['近卫干员', '减速'], 4],
[['近战位', '减速'], 4],
[['输出', '减速'], 4],
[['近卫干员', '支援'], 4],
[['输出', '支援'], 4],
[['近战位', '支援'], 4],
[['支援'], 4],
[['重装干员', '输出'], 5],
[['防护', '输出'], 5],
[['重装干员', '生存'], 5],
[['防护', '生存'], 5],
[['重装干员', '输出'], 5],
[['防护', '输出'], 5],
[['重装干员', '位移'], 5],
[['防护', '位移'], 5],
[['削弱', '群攻'], 5],
[['狙击干员', '爆发'], 5],
[['远程位', '爆发'], 5],
[['狙击干员', '生存'], 4],
[['远程位', '生存'], 4],
[['狙击干员', '减速'], 4],
[['输出', '减速'], 4],
[['输出', '削弱'], 4],
[['狙击干员', '削弱'], 4],
[['远程位', '削弱'], 4],
[['削弱'], 4],
[['召唤'], 5],
[['特种'], 4],
[['位移'], 4],
[['控场'], 4],
[['快速复活'], 4],
[['狙击干员'], 3],
[['近战干员'], 3],
[['医疗干员'], 3],
[['辅助干员'], 3],
[['狙击干员'], 3],
[['群攻'], 3],
[['术士干员'], 3],
[['近战位'], 3],
[['远程位'], 3],
[['输出'], 3],
[['生存'], 3],
# 白雪
#
# 狙击 + 减速30 %
#
# 群攻 + 减速50 %
#
# 夜魔
#
# 术师 + 治疗100 %
#
# 输出 + 治疗100 %
#
# 莱恩哈特
#
# 术师 + 爆发100 %
#
# 远程 + 爆发50 %
#
# 蜜蜡
#
# 术师 + 防护100 %
#
# 远程 + 防护100 %
#
# 群攻 + 防护100 %
#
# 夜烟
#
# 术师 + 削弱100 %
#
# 输出 + 削弱50 %
#
# 远程 + 削弱45 %
#
# 削弱45 %
#
# 卡达
#
# 控场95 %
#
# 输出 + 控场100 %
#
# 术师 + 控场100 %
#
# 格雷伊
#
# 术师 + 减速99 %
#
# 群攻 + 减速50 %
#
# 清流
#
# 医疗 + 支援98 %
#
# 治疗 + 支援98 %
#
# 远程 + 支援97 %
#
# 支援45 %
#
# 初雪 / 巫恋
#
# 辅助 + 削弱50 %
#
# 月禾
#
# 辅助 + 支援100 %
#
# 辅助 + 生存100 %
#
# 生存 + 支援100 %
#
# 格劳克斯
#
# 减速 + 控场100 %
#
# 辅助 + 控场50 %
#
# 真理
#
# 辅助 + 输出100 %
#
# 梅尔
#
# 召唤100 %
#
# 辅助 + 控场50 %
#
# 波登可
#
# 辅助 + 治疗100 %
#
# 减速 + 治疗99 %
#
# 狮蝎
#
# 特种 + 生存100 %
#
# 槐琥
#
# 特种 + 削弱100 %
#
# 快速复活 + 削弱100 %
#
# 近战 + 削弱100 %
#
# 红
#
# 特种 + 控场100 %
#
# 快速复活 + 控场100 %
#
# 近战 + 控场50 %
#
# 崖心
#
# 位移 + 输出100 %
#
# 食铁兽
#
# 特种 + 减速100 %
#
# 位移 + 减速100 %
#
# 暗锁
#
# 快速复活 + 输出100 %
#
# 特种 + 输出98 %
#
# 快速复活49 % 特种25 %
#
# 阿消
#
# 特种 + 位移48 %
#
# 特种25 %
#
# 砾
#
# 特种 + 防护100 %
#
# 快速复活 + 防护100 %
#
# 快速复活49 %
#
# 特种25 %
#
# 阿消 / 暗锁
#
# 特种 + 位移48 %
#
# 特种25 %
]
office_priority = {
'office1': ['res/pictures/office1.png', '5'],
'office2': ['res/pictures/office2.png', '4'],
'office3': ['res/pictures/office3.png', '3'],
'office4': ['res/pictures/office4.png', '2']
}
electricity_priority = {
'electricity1': ['res/pictures/electricity1.png', '5'],
'electricity2': ['res/pictures/electricity2.png', '4'],
'electricity3': ['res/pictures/electricity3.png', '3'],
'electricity4': ['res/pictures/electricity4.png', '2']
}
dormitory_priority = {
'bad_mood': ['res/pictures/bad_mood.png', '5'],
'common_mood': ['res/pictures/common_mood.png', '4']
'bad_common_mood': ['res/pictures/bad_common_mood.png', '4'],
'bad_common_mood2': ['res/pictures/bad_common_mood2.png', '3'],
'bad_common_mood3': ['res/pictures/bad_common_mood3.png', '2'],
}
producing_experience_priority = {
'top_experience': ['res/pictures/experience_top.png', '5'],

@ -1,5 +1,5 @@
import sys
import sys
from PyQt5.QtWidgets import QApplication, QMainWindow, QPushButton, QListWidget, QListWidgetItem, QComboBox
from PyQt5.QtCore import Qt
from PyQt5 import uic
@ -8,37 +8,43 @@ from translate_window import translate
from settingrule_window import settingrule
from selectRuleOrder import orderselet
from control.controltools.setShotArea import SetShotArea
import tkinter as tk
from windows.control.controltools.regPictrue import RegPictrue
from windows.control.database.sqdatabase import DatabaseHandler
from windows.res.tools.auto_game import autogame
class MyApp(QMainWindow):
def __init__(self):
super().__init__()
super(QMainWindow, self).__init__()
self.target_list = None
self.my_thread = None
uic.loadUi('res/ui/main_window.ui', self)
DatabaseHandler.init_db()
self.shotArea = None
self.shotArea = None # 默认识别区域
self.regPicture = None
self.translate_state = False
self.selected_language = "en"
self.select_language = ''
self.translate_window = translate()
self.setRule_window = settingrule()
self.orderSelect_window = orderselet()
self.setRule_window = settingrule(self)
self.orderSelect_window = orderselet(self)
# 初始化主界面的按钮
self.addRuleBtn = self.findChild(QPushButton, 'addRuleBtn')
self.delRuleBtn = self.findChild(QPushButton, 'delRuleBtn')
self.translateBtn = self.findChild(QPushButton, 'translateBtn')
self.autoplay = self.findChild(QPushButton, 'autoGameBtn')
self.ruleList = self.findChild(QListWidget, 'ruleList')
self.language = self.findChild(QComboBox, 'language')
self.choseLocationBtn = self.findChild(QPushButton, 'choseLocationBtn')
# 语言选择列表的改变
self.language.activated.connect(self.selectTransLanguage)
# 点击翻译区域选择,触发截屏事件
self.choseLocationBtn.clicked.connect(self.setShotAreaFun)
# 点击每个按钮触发跳转界面事件
self.addRuleBtn.clicked.connect(self.show_settingrule_window)
self.translateBtn.clicked.connect(self.show_translate_window)
self.autoplay.clicked.connect(self.show_orderselect_window)
@ -49,36 +55,116 @@ class MyApp(QMainWindow):
# 连接itemClicked信号到槽函数
self.ruleList.itemClicked.connect(self.onItemClicked)
self.listIndexs = self.get_item_indexs(self.ruleList)
self.add_listitem()
self.delruleBtn = self.findChild(QPushButton, 'delRuleBtn')
self.delruleBtn.clicked.connect(self.delete_genrule)
def startgame(self, orderlist):
# genrule_count = orderlist.count() # 获取 QListWidget 中的列表项数量
#
# for i in range(genrule_count):
# item = orderlist.item(i) # 获取索引为 i 的列表项
# print(item.text())
# Assuming self.order_list is the source QListWidget
# Create a new QListWidget as the target
self.target_list = QListWidget()
# Copy items from the source to the target
for index in range(orderlist.count()):
item = orderlist.item(index)
cloned_item = QListWidgetItem(item.text()) # Clone the item with its text
self.target_list.addItem(cloned_item)
self.my_thread = autogame(self.target_list)
self.my_thread.finished.connect(self.on_thread_finished)
self.my_thread.start()
def on_thread_finished(self):
# 此方法将在线程完成其工作时调用
# 在线程完成后执行任何其他操作
print('over')
def delete_genrule(self):
db = DatabaseHandler(database='test2.sqlite3')
db.connect()
rule_count = self.ruleList.count()
for i in range(rule_count):
item = self.ruleList.item(i)
if item.checkState() == Qt.Checked:
path = item.text()
path = str(path)
print(path)
db.cur.execute("SELECT pid FROM userGeneralRule WHERE path = ?", (path,))
rows = db.cur.fetchall()
pid = int(rows[0][0])
db.delete_row('userGeneralRule', pid)
db.close()
self.add_listitem()
def add_listitem(self):
self.ruleList.clear()
item = QListWidgetItem('明日方舟自动清体力')
item.setCheckState(Qt.Unchecked)
self.ruleList.addItem(item)
item = QListWidgetItem('明日方舟换基建')
item.setCheckState(Qt.Unchecked)
self.ruleList.addItem(item)
item = QListWidgetItem('明日方舟公开招募')
item.setCheckState(Qt.Unchecked)
self.ruleList.addItem(item)
item = QListWidgetItem('明日方舟日常处理')
item.setCheckState(Qt.Unchecked)
self.ruleList.addItem(item)
db = DatabaseHandler(database='test2.sqlite3')
db.connect()
db.cur.execute(f"SELECT * FROM userGeneralRule")
data = db.cur.fetchall()
my_list = []
for row in data:
name = row[2]
if name: # 确保name不为空
value = row[0]
element = {"name": name, "value": value}
my_list.append(element)
db.close()
for element in my_list:
item = QListWidgetItem(element["name"])
item.setCheckState(Qt.Unchecked)
self.ruleList.addItem(item)
# self.ruleList.addItem('name')
def showTransText(self):
window = tk.Tk()
text = 'null'
label = tk.Label(window, text=text, font=("Arial", 24))
label.pack()
window.mainloop()
# 翻译功能的相关函数
def setShotAreaFun(self): # 设置截图区域
shot = SetShotArea()
self.shotArea = shot.setShotArea()
def show_orderselect_window(self):
item_states = self.get_item_states(self.ruleList)
for item_text, item_state in item_states.items():
if item_state == Qt.Checked:
item = QListWidgetItem(item_text)
item.setFlags(item.flags() | Qt.ItemIsSelectable | Qt.ItemIsUserCheckable | Qt.ItemIsEnabled)
item.setCheckState(Qt.Unchecked)
self.orderSelect_window.order_list.addItem(item)
self.orderSelect_window.show()
def show_settingrule_window(self):
self.setRule_window.show()
def show_translate_window(self):
def show_translate_window(self, index):
self.showMinimized()
self.change_translate_state()
# 结束翻译
if self.translate_state is False:
self.translate_window.close()
if self.regPicture is not None:
self.regPicture.isOpen = False
# 开始翻译
elif self.translate_state is True:
self.translate_window.show()
# 调用截屏功能时
if self.shotArea is not None:
self.regPicture = RegPictrue(self.shotArea, self.translate_window)
self.regPicture.setLanguage(self.select_language)
self.regPicture.org_words.connect(self.orgWords)
self.regPicture.translate_words.connect(self.translate_words)
self.regPicture.start()
@ -89,6 +175,48 @@ class MyApp(QMainWindow):
def translate_words(self, twords):
self.translate_window.transwords.setText(twords)
def selectTransLanguage(self, index): # 各种语言选项的返回值
selected_language = self.language.itemText(index)
self.regPicture = RegPictrue(self.shotArea, self.translate_window)
if selected_language == "日语":
self.select_language = "ja"
elif selected_language == "法语":
self.select_language = "fr"
elif selected_language == "英语":
self.select_language = "en"
elif selected_language == "中文":
self.select_language = "zh"
# def show_orderselect_window(self):
# item_states = self.get_item_states(self.ruleList)
# for item_text, item_state in item_states.items():
# if item_state == Qt.Checked:
# item = QListWidgetItem(item_text)
# item.setFlags(item.flags() | Qt.ItemIsSelectable | Qt.ItemIsUserCheckable | Qt.ItemIsEnabled)
# item.setCheckState(Qt.Unchecked)
# self.orderSelect_window.order_list.addItem(item)
# self.orderSelect_window.show()
def show_orderselect_window(self):
self.showMinimized()
index = 1
item_states = self.get_item_states(self.ruleList)
for item_text, item_state in item_states.items():
if item_state == Qt.Checked:
item = QListWidgetItem(str(index) + ":" + item_text) # str(index)+":"+
item.setFlags(item.flags() | Qt.ItemIsSelectable | Qt.ItemIsUserCheckable | Qt.ItemIsEnabled)
# item.setCheckState(Qt.Unchecked)
self.orderSelect_window.order_list.addItem(item)
index += 1
self.orderSelect_window.show()
def show_settingrule_window(self):
self.showMinimized()
self.setRule_window.show()
# self.setRule_window.setWindowFlags(Qt.WindowStaysOnTopHint) # 设置为最上层
self.setRule_window.showNormal()
self.setRule_window.raise_() # Bring the window to the front
def change_translate_state(self):
# 处理项目的选择状态变化
if self.translate_state is False:
@ -107,8 +235,7 @@ class MyApp(QMainWindow):
else:
item.setCheckState(Qt.Checked)
@staticmethod
def get_item_states(list_widget):
def get_item_states(self, list_widget):
item_states = {} # 用于存储项目的选择状态
for index in range(list_widget.count()):
@ -119,8 +246,7 @@ class MyApp(QMainWindow):
item_states[item_text] = item_state
return item_states
@staticmethod
def get_item_indexs(list_widget):
def get_item_indexs(self, list_widget):
item_indexs = {} # 用于建项目的选择状态
for index in range(list_widget.count()):
@ -130,15 +256,6 @@ class MyApp(QMainWindow):
item_indexs[item_text] = index
return item_indexs
def selectTransLanguage(self, index): # 各种语言选项的返回值
selected_language = self.language.itemText(index)
if selected_language == "日语":
print("jpn")
elif selected_language == "法语":
print("fra")
elif selected_language == "英语":
print("en")
if __name__ == "__main__":
app = QApplication(sys.argv)

@ -1,51 +0,0 @@
from PyQt5.QtWidgets import QMainWindow, QWidget, QGridLayout, QLabel, QPushButton
from PyQt5 import uic
class operateselect(QMainWindow):
def __init__(self):
super().__init__()
self.selectedWidget = None
uic.loadUi('res/ui/operationSelect_window.ui', self)
self.findQGridLayout()
self.confirmBtn = self.findChild(QPushButton, 'confirmBtn')#确定按钮
self.confirmBtn.clicked.connect(self.confirm_clicked)
def confirm_clicked(self):
print("已选择:", self.getOperator())
self.close()
def findQGridLayout(self): # 找到QGridLayout
grid_layout = self.findChild(QGridLayout, "gridLayout")
if grid_layout:
for i in range(grid_layout.rowCount()):
for j in range(grid_layout.columnCount()):
item = grid_layout.itemAtPosition(i, j)
if item and isinstance(item.widget(), QWidget):
widget = item.widget()
widget.mousePressEvent = lambda event, clickedwidget=widget: self.onWidgetClicked(clickedwidget)
self.selectedWidget = None
def onWidgetClicked(self, clickedwidget):
# 将之前被选中的QWidget的背景颜色恢复为默认
if self.selectedWidget:
self.selectedWidget.setStyleSheet("background-color: none;")
# 设置被选中的QWidget的背景颜色为浅蓝色
clickedwidget.setStyleSheet("background-color: lightblue;")
self.selectedWidget = clickedwidget
label = self.selectedWidget.findChild(QLabel)
if label:
print("选中的标签文本:", label.text())
self.setOperator(label.text())
else:
print("未找到标签文本")
def setOperator(self,opt_text):#获取到操作类型值
self.operator_text = opt_text
def getOperator(self):#返回操作类型值
return self.operator_text

@ -0,0 +1,885 @@
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'operationSelect_window.ui'
#
# Created by: PyQt5 UI code generator 5.15.9
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
from tkinter import filedialog
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets import QWidget, QLabel
from pyqt5_plugins.examplebuttonplugin import QtGui
from control.database.sqdatabase import *
from res.pictures.ScreenCapture import ScreenCapture
from res.rules.howoperation import DatabaseControl
class operatation_select(object):
def __init__(self, last_window):
super().__init__()
self.operator_text = None
self.window = QWidget()
self.setupUi(self.window)
self.last_window = last_window
def setupUi(self, Form):
Form.setObjectName("Form")
Form.resize(676, 580)
self.widget_9 = QtWidgets.QWidget(Form)
self.widget_9.setGeometry(QtCore.QRect(0, 0, 671, 581))
self.widget_9.setObjectName("widget_9")
self.layoutWidget = QtWidgets.QWidget(self.widget_9)
self.layoutWidget.setGeometry(QtCore.QRect(10, 10, 641, 321))
self.layoutWidget.setObjectName("layoutWidget")
self.gridLayout = QtWidgets.QGridLayout(self.layoutWidget)
self.gridLayout.setContentsMargins(0, 0, 0, 0)
self.gridLayout.setObjectName("gridLayout")
self.widget = QtWidgets.QWidget(self.layoutWidget)
self.widget.setObjectName("widget")
self.verticalLayout = QtWidgets.QVBoxLayout(self.widget)
self.verticalLayout.setObjectName("verticalLayout")
self.opr_mouseClick = QtWidgets.QGraphicsView(self.widget)
self.opr_mouseClick.setObjectName("opr_mouseClick")
# 创建QGraphicsScene
self.scene = QtWidgets.QGraphicsScene(self.opr_mouseClick)
self.opr_mouseClick.setScene(self.scene)
# 加载图片
image_path = "res/ui/picture/延时时间.png"
pixmap = QtGui.QPixmap(image_path)
scaled_pixmap = pixmap.scaled(95, 95) # 100x100 是你想要的新大小
item1 = QtWidgets.QGraphicsPixmapItem(scaled_pixmap)
self.scene.addItem(item1)
self.verticalLayout.addWidget(self.opr_mouseClick)
self.delay = QtWidgets.QLabel(self.widget)
self.delay.setTextFormat(QtCore.Qt.AutoText)
self.delay.setAlignment(QtCore.Qt.AlignCenter)
self.delay.setObjectName("delay")
self.verticalLayout.addWidget(self.delay)
self.gridLayout.addWidget(self.widget, 0, 0, 1, 1)
self.widget_2 = QtWidgets.QWidget(self.layoutWidget)
self.widget_2.setObjectName("widget_2")
self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.widget_2)
self.verticalLayout_2.setObjectName("verticalLayout_2")
self.opr_holdTap = QtWidgets.QGraphicsView(self.widget_2)
self.opr_holdTap.setObjectName("opr_holdTap")
# 创建QGraphicsScene
self.scene = QtWidgets.QGraphicsScene(self.opr_holdTap)
self.opr_holdTap.setScene(self.scene)
# 加载图片
image_path = "res/ui/picture/线性左滑.png"
pixmap = QtGui.QPixmap(image_path)
scaled_pixmap = pixmap.scaled(95, 95) # 100x100 是你想要的新大小
item2 = QtWidgets.QGraphicsPixmapItem(scaled_pixmap)
self.scene.addItem(item2)
self.verticalLayout_2.addWidget(self.opr_holdTap)
self.left_slide = QtWidgets.QLabel(self.widget_2)
self.left_slide.setAlignment(QtCore.Qt.AlignCenter)
self.left_slide.setObjectName("left_slide")
self.verticalLayout_2.addWidget(self.left_slide)
self.gridLayout.addWidget(self.widget_2, 0, 1, 1, 1)
self.widget_3 = QtWidgets.QWidget(self.layoutWidget)
self.widget_3.setObjectName("widget_3")
self.verticalLayout_3 = QtWidgets.QVBoxLayout(self.widget_3)
self.verticalLayout_3.setObjectName("verticalLayout_3")
self.opr_left = QtWidgets.QGraphicsView(self.widget_3)
self.opr_left.setObjectName("opr_left")
# 创建QGraphicsScene
self.scene = QtWidgets.QGraphicsScene(self.opr_left)
self.opr_left.setScene(self.scene)
# 加载图片
image_path = "res/ui/picture/线性左滑.png"
pixmap = QtGui.QPixmap(image_path)
scaled_pixmap = pixmap.scaled(95, 95) # 100x100 是你想要的新大小
item3 = QtWidgets.QGraphicsPixmapItem(scaled_pixmap)
self.scene.addItem(item3)
self.verticalLayout_3.addWidget(self.opr_left)
self.right_slide = QtWidgets.QLabel(self.widget_3)
self.right_slide.setAlignment(QtCore.Qt.AlignCenter)
self.right_slide.setObjectName("right_slide")
self.verticalLayout_3.addWidget(self.right_slide)
self.gridLayout.addWidget(self.widget_3, 0, 2, 1, 1)
self.widget_4 = QtWidgets.QWidget(self.layoutWidget)
self.widget_4.setObjectName("widget_4")
self.verticalLayout_4 = QtWidgets.QVBoxLayout(self.widget_4)
self.verticalLayout_4.setObjectName("verticalLayout_4")
self.opr_rignt = QtWidgets.QGraphicsView(self.widget_4)
self.opr_rignt.setObjectName("opr_rignt")
# 创建QGraphicsScene
self.scene = QtWidgets.QGraphicsScene(self.opr_rignt)
self.opr_rignt.setScene(self.scene)
# 加载图片
image_path = "res/ui/picture/线性右滑.png"
pixmap = QtGui.QPixmap(image_path)
scaled_pixmap = pixmap.scaled(95, 95) # 100x100 是你想要的新大小
item4 = QtWidgets.QGraphicsPixmapItem(scaled_pixmap)
self.scene.addItem(item4)
self.verticalLayout_4.addWidget(self.opr_rignt)
self.front_slide = QtWidgets.QLabel(self.widget_4)
self.front_slide.setAlignment(QtCore.Qt.AlignCenter)
self.front_slide.setObjectName("front_slide")
self.verticalLayout_4.addWidget(self.front_slide)
self.gridLayout.addWidget(self.widget_4, 0, 3, 1, 1)
self.widget_6 = QtWidgets.QWidget(self.layoutWidget)
self.widget_6.setObjectName("widget_6")
self.verticalLayout_6 = QtWidgets.QVBoxLayout(self.widget_6)
self.verticalLayout_6.setObjectName("verticalLayout_6")
self.opr_sleep = QtWidgets.QGraphicsView(self.widget_6)
self.opr_sleep.setObjectName("opr_sleep")
# 创建QGraphicsScene
self.scene = QtWidgets.QGraphicsScene(self.opr_sleep)
self.opr_sleep.setScene(self.scene)
# 加载图片
image_path = "res/ui/picture/上滑.png"
pixmap = QtGui.QPixmap(image_path)
scaled_pixmap = pixmap.scaled(95, 95) # 100x100 是你想要的新大小
item5 = QtWidgets.QGraphicsPixmapItem(scaled_pixmap)
self.scene.addItem(item5)
self.verticalLayout_6.addWidget(self.opr_sleep)
self.open_doc = QtWidgets.QLabel(self.widget_6)
self.open_doc.setAlignment(QtCore.Qt.AlignCenter)
self.open_doc.setObjectName("open_doc")
self.verticalLayout_6.addWidget(self.open_doc)
self.gridLayout.addWidget(self.widget_6, 1, 0, 1, 1)
self.widget_7 = QtWidgets.QWidget(self.layoutWidget)
self.widget_7.setObjectName("widget_7")
self.verticalLayout_7 = QtWidgets.QVBoxLayout(self.widget_7)
self.verticalLayout_7.setObjectName("verticalLayout_7")
self.opr_up = QtWidgets.QGraphicsView(self.widget_7)
self.opr_up.setObjectName("opr_up")
# 创建QGraphicsScene
self.scene = QtWidgets.QGraphicsScene(self.opr_up)
self.opr_up.setScene(self.scene)
# 加载图片
image_path = "res/ui/picture/文件.jpg"
pixmap = QtGui.QPixmap(image_path)
scaled_pixmap = pixmap.scaled(95, 95) # 100x100 是你想要的新大小
item6 = QtWidgets.QGraphicsPixmapItem(scaled_pixmap)
self.scene.addItem(item6)
self.verticalLayout_7.addWidget(self.opr_up)
self.click_photo = QtWidgets.QLabel(self.widget_7)
self.click_photo.setAlignment(QtCore.Qt.AlignCenter)
self.click_photo.setObjectName("click_photo")
self.verticalLayout_7.addWidget(self.click_photo)
self.gridLayout.addWidget(self.widget_7, 1, 1, 1, 1)
self.widget_5 = QtWidgets.QWidget(self.layoutWidget)
self.widget_5.setObjectName("widget_5")
self.verticalLayout_5 = QtWidgets.QVBoxLayout(self.widget_5)
self.verticalLayout_5.setObjectName("verticalLayout_5")
self.opr_keyClick = QtWidgets.QGraphicsView(self.widget_5)
self.opr_keyClick.setObjectName("opr_keyClick")
# 创建QGraphicsScene
self.scene = QtWidgets.QGraphicsScene(self.opr_keyClick)
self.opr_keyClick.setScene(self.scene)
# 加载图片
image_path = "res/ui/picture/点击.png"
pixmap = QtGui.QPixmap(image_path)
scaled_pixmap = pixmap.scaled(95, 95) # 100x100 是你想要的新大小
item7 = QtWidgets.QGraphicsPixmapItem(scaled_pixmap)
self.scene.addItem(item7)
self.verticalLayout_5.addWidget(self.opr_keyClick)
self.back_slide = QtWidgets.QLabel(self.widget_5)
self.back_slide.setAlignment(QtCore.Qt.AlignCenter)
self.back_slide.setObjectName("back_slide")
self.verticalLayout_5.addWidget(self.back_slide)
self.gridLayout.addWidget(self.widget_5, 0, 4, 1, 1)
self.widget_8 = QtWidgets.QWidget(self.layoutWidget)
self.widget_8.setObjectName("widget_8")
self.verticalLayout_8 = QtWidgets.QVBoxLayout(self.widget_8)
self.verticalLayout_8.setObjectName("verticalLayout_8")
self.opr_up_2 = QtWidgets.QGraphicsView(self.widget_8)
self.opr_up_2.setObjectName("opr_up_2")
# 创建QGraphicsScene
self.scene = QtWidgets.QGraphicsScene(self.opr_up_2)
self.opr_up_2.setScene(self.scene)
# 加载图片
image_path = "res/ui/picture/下滑.png"
pixmap = QtGui.QPixmap(image_path)
scaled_pixmap = pixmap.scaled(95, 95) # 100x100 是你想要的新大小
item8 = QtWidgets.QGraphicsPixmapItem(scaled_pixmap)
self.scene.addItem(item8)
self.verticalLayout_8.addWidget(self.opr_up_2)
self.click_photo_2 = QtWidgets.QLabel(self.widget_8)
self.click_photo_2.setAlignment(QtCore.Qt.AlignCenter)
self.click_photo_2.setObjectName("click_photo_2")
self.verticalLayout_8.addWidget(self.click_photo_2)
self.gridLayout.addWidget(self.widget_8, 1, 2, 1, 1)
self.widget_11 = QtWidgets.QWidget(self.layoutWidget)
self.widget_11.setObjectName("widget_11")
self.verticalLayout_9 = QtWidgets.QVBoxLayout(self.widget_11)
self.verticalLayout_9.setObjectName("verticalLayout_9")
self.opr_up_3 = QtWidgets.QGraphicsView(self.widget_11)
self.opr_up_3.setObjectName("opr_up_3")
# 创建QGraphicsScene
self.scene = QtWidgets.QGraphicsScene(self.opr_up_3)
self.opr_up_3.setScene(self.scene)
# 加载图片
image_path = "res/ui/picture/长按.png"
pixmap = QtGui.QPixmap(image_path)
scaled_pixmap = pixmap.scaled(95, 95) # 100x100 是你想要的新大小
item9 = QtWidgets.QGraphicsPixmapItem(scaled_pixmap)
self.scene.addItem(item9)
self.verticalLayout_9.addWidget(self.opr_up_3)
self.click_photo_3 = QtWidgets.QLabel(self.widget_11)
self.click_photo_3.setAlignment(QtCore.Qt.AlignCenter)
self.click_photo_3.setObjectName("click_photo_3")
self.verticalLayout_9.addWidget(self.click_photo_3)
self.gridLayout.addWidget(self.widget_11, 1, 3, 1, 1)
self.widget_12 = QtWidgets.QWidget(self.layoutWidget)
self.widget_12.setObjectName("widget_12")
self.verticalLayout_10 = QtWidgets.QVBoxLayout(self.widget_12)
self.verticalLayout_10.setObjectName("verticalLayout_9")
self.opr_u = QtWidgets.QGraphicsView(self.widget_12)
self.opr_u.setObjectName("opr_up_3")
# 创建QGraphicsScene
self.scene = QtWidgets.QGraphicsScene(self.opr_u)
self.opr_u.setScene(self.scene)
# 加载图片
image_path = "res/ui/picture/输入.png"
pixmap = QtGui.QPixmap(image_path)
scaled_pixmap = pixmap.scaled(95, 95) # 100x100 是你想要的新大小
item10 = QtWidgets.QGraphicsPixmapItem(scaled_pixmap)
self.scene.addItem(item10)
self.verticalLayout_10.addWidget(self.opr_u)
self.click_photo_4 = QtWidgets.QLabel(self.widget_12)
self.click_photo_4.setAlignment(QtCore.Qt.AlignCenter)
self.click_photo_4.setObjectName("click_photo_4")
self.verticalLayout_10.addWidget(self.click_photo_4)
self.gridLayout.addWidget(self.widget_12, 1, 4, 1, 1)
self.confirmBtn = QtWidgets.QPushButton(self.widget_9)
self.confirmBtn.setGeometry(QtCore.QRect(500, 490, 119, 71))
self.confirmBtn.setObjectName("confirmBtn")
self.confirmBtn.clicked.connect(self.getInputs)
self.delay_time = QtWidgets.QLineEdit(self.widget_9)
self.delay_time.setGeometry(QtCore.QRect(200, 500, 151, 41))
self.delay_time.setObjectName("delay_time")
self.widget_10 = QtWidgets.QWidget(self.widget_9)
self.widget_10.setGeometry(QtCore.QRect(10, 340, 651, 161))
self.widget_10.setObjectName("widget_10")
self.comboBox = QtWidgets.QComboBox(self.widget_10)
self.comboBox.setGeometry(QtCore.QRect(70, 20, 131, 41))
self.comboBox.setObjectName("comboBox")
self.comboBox.addItem("")
self.comboBox.addItem("")
self.comboBox.addItem("")
self.position_word = QtWidgets.QLabel(self.widget_10)
self.position_word.setGeometry(QtCore.QRect(20, 20, 71, 41))
self.position_word.setObjectName("position_word")
self.shothoto = QtWidgets.QPushButton(self.widget_10)
self.shothoto.setGeometry(QtCore.QRect(220, 20, 71, 41))
self.shothoto.setObjectName("shothoto")
self.shothoto.clicked.connect(self.getJpgPath)
self.up_photo = QtWidgets.QPushButton(self.widget_10)
self.up_photo.setGeometry(QtCore.QRect(310, 20, 71, 41))
self.up_photo.setObjectName("up_photo")
self.up_photo.clicked.connect(self.select_file)
self.word = QtWidgets.QLineEdit(self.widget_10)
self.word.setGeometry(QtCore.QRect(230, 20, 151, 41))
self.word.setObjectName("word")
self.position_offset = QtWidgets.QLabel(self.widget_10)
self.position_offset.setGeometry(QtCore.QRect(10, 60, 241, 31))
self.position_offset.setObjectName("position_offset")
self.x_word = QtWidgets.QLabel(self.widget_10)
self.x_word.setGeometry(QtCore.QRect(10, 100, 72, 15))
self.x_word.setObjectName("x_word")
self.y_word = QtWidgets.QLabel(self.widget_10)
self.y_word.setGeometry(QtCore.QRect(150, 100, 72, 15))
self.y_word.setObjectName("y_word")
self.xposition = QtWidgets.QLineEdit(self.widget_10)
self.xposition.setGeometry(QtCore.QRect(40, 100, 81, 21))
self.xposition.setObjectName("xposition")
self.yposition = QtWidgets.QLineEdit(self.widget_10)
self.yposition.setGeometry(QtCore.QRect(180, 100, 81, 21))
self.yposition.setObjectName("yposition")
self.distence_word = QtWidgets.QLabel(self.widget_10)
self.distence_word.setGeometry(QtCore.QRect(30, 140, 72, 15))
self.distence_word.setObjectName("distence_word")
self.distence = QtWidgets.QLineEdit(self.widget_10)
self.distence.setGeometry(QtCore.QRect(70, 130, 81, 31))
self.distence.setObjectName("distence")
self.photo_name_word = QtWidgets.QLabel(self.widget_10)
self.photo_name_word.setGeometry(QtCore.QRect(400, 20, 71, 41))
self.photo_name_word.setObjectName("photo_name_word")
self.photo_name = QtWidgets.QLineEdit(self.widget_10)
self.photo_name.setGeometry(QtCore.QRect(480, 20, 151, 41))
self.photo_name.setObjectName("photo_name")
self.comboBox.raise_()
self.position_word.raise_()
self.word.raise_()
self.position_offset.raise_()
self.x_word.raise_()
self.y_word.raise_()
self.xposition.raise_()
self.yposition.raise_()
self.up_photo.raise_()
self.shothoto.raise_()
self.distence_word.raise_()
self.distence.raise_()
self.photo_name_word.raise_()
self.photo_name.raise_()
self.delay_time_word = QtWidgets.QLabel(self.widget_9)
self.delay_time_word.setGeometry(QtCore.QRect(20, 490, 151, 71))
self.delay_time_word.setObjectName("delay_time_word")
self.times = QtWidgets.QLabel(self.widget_9)
self.times.setGeometry(QtCore.QRect(40, 490, 151, 71))
self.times.setObjectName("times")
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
self.confirmBtn.clicked.connect(self.confirm_clicked) # Connect the button click to your method
self.findQGridLayout()
self.set_visibility()
self.comboBox.currentIndexChanged.connect(self.handleComboBoxActivated)
def retranslateUi(self, Form):
_translate = QtCore.QCoreApplication.translate
Form.setWindowTitle(_translate("Form", "Form"))
self.opr_mouseClick.setToolTip(_translate("Form", "<html><head/><body><p><br/></p></body></html>"))
self.opr_mouseClick.setWhatsThis(_translate("Form", "<html><head/><body><p>12</p></body></html>"))
self.delay.setText(_translate("Form", "延时操作"))
self.left_slide.setText(_translate("Form", "左滑操作"))
self.right_slide.setText(_translate("Form", "右滑操作"))
self.front_slide.setText(_translate("Form", "上滑操作"))
self.open_doc.setText(_translate("Form", "打开文件"))
self.click_photo.setText(_translate("Form", "点击操作"))
self.back_slide.setText(_translate("Form", "下滑操作"))
self.click_photo_2.setText(_translate("Form", "长按操作"))
self.click_photo_3.setText(_translate("Form", "开始循环"))
self.click_photo_4.setText(_translate("Form", "输入操作"))
self.confirmBtn.setText(_translate("Form", "确认"))
self.comboBox.setItemText(0, _translate("Form", "图片"))
self.comboBox.setItemText(1, _translate("Form", "文字"))
self.comboBox.setItemText(2, _translate("Form", "固定点"))
self.position_word.setText(_translate("Form", "<html><head/><body><p>位置:</p></body></html>"))
self.shothoto.setText(_translate("Form", "截图"))
self.up_photo.setText(_translate("Form", "上传"))
self.position_offset.setText(
_translate("Form", "<html><head/><body><p>位置偏移从0或图片文字开始</p></body></html>"))
self.x_word.setText(_translate("Form", "x"))
self.y_word.setText(_translate("Form", "y"))
self.distence_word.setText(_translate("Form", "距离:"))
self.photo_name_word.setText(_translate("Form", "<html><head/><body><p>图片名字:</p></body></html>"))
self.delay_time_word.setText(_translate("Form",
"<html><head/><body><p><span style=\" font-size:18pt; "
"font-weight:600; font-style:italic;\">延时时间:</span></p></body></html>"))
self.times.setText(_translate("Form",
"<html><head/><body><p><span style=\" "
"font-size:18pt;\">执行次数:</span></p></body></html>"))
def handleComboBoxActivated(self, index):
selected_option = self.comboBox.itemText(index)
if selected_option == "图片":
self.up_photo.setVisible(True)
self.shothoto.setVisible(True)
self.word.setVisible(False)
elif selected_option == "文字":
self.up_photo.setVisible(False)
self.shothoto.setVisible(False)
self.word.setVisible(True)
elif selected_option == "固定点":
self.up_photo.setVisible(False)
self.shothoto.setVisible(False)
self.word.setVisible(False)
def getJpgPath(self): # 20 找到图片
sc = ScreenCapture()
path = sc.capture_screen()
self.photo_name.setText(path)
def confirm_clicked(self):
if self.getOperator() is not None:
print("已选择:", self.getOperator())
self.window.close()
def findQGridLayout(self): # 找到QGridLayout
if self.gridLayout:
for i in range(self.gridLayout.rowCount()):
for j in range(self.gridLayout.columnCount()):
item = self.gridLayout.itemAtPosition(i, j)
if item and isinstance(item.widget(), QWidget):
widget = item.widget()
widget.mousePressEvent = lambda event, clickedwidget=widget: self.onWidgetClicked(clickedwidget)
self.selectedWidget = None
def onWidgetClicked(self, clickedwidget):
# Check if the clicked widget is the same as the currently selected widget
if self.selectedWidget and self.selectedWidget == clickedwidget:
# Reset the background color
clickedwidget.setStyleSheet("background-color: none;")
self.selectedWidget = None
self.operator_text = None
self.set_visibility()
else:
# Reset the background color of the previously selected widget, if any
if self.selectedWidget:
self.selectedWidget.setStyleSheet("background-color: none;")
# Set the background color of the clicked widget
clickedwidget.setStyleSheet("background-color: lightblue;")
self.selectedWidget = clickedwidget
label = self.selectedWidget.findChild(QLabel)
if label:
if label.text() == '延时操作':
targets = [
self.delay_time,
self.delay_time_word,
]
self.set_visibility(targets)
elif label.text() == '左滑操作':
targets = [
self.comboBox, self.position_word,
self.shothoto, self.up_photo,
self.position_offset, self.x_word,
self.y_word, self.xposition, self.yposition,
self.distence_word, self.distence,
self.times, self.delay_time,
]
self.set_visibility(targets)
elif label.text() == '右滑操作':
targets = [
self.comboBox, self.position_word,
self.shothoto, self.up_photo,
self.position_offset, self.x_word,
self.y_word, self.xposition, self.yposition,
self.distence_word, self.distence,
self.times, self.delay_time,
]
self.set_visibility(targets)
elif label.text() == '上滑操作':
targets = [
self.comboBox, self.position_word,
self.shothoto, self.up_photo,
self.position_offset, self.x_word,
self.y_word, self.xposition, self.yposition,
self.distence_word, self.distence,
self.times, self.delay_time,
]
self.set_visibility(targets)
elif label.text() == '下滑操作':
targets = [
self.comboBox, self.position_word,
self.shothoto, self.up_photo,
self.position_offset, self.x_word,
self.y_word, self.xposition, self.yposition,
self.distence_word, self.distence,
self.times, self.delay_time,
]
self.set_visibility(targets)
elif label.text() == '打开文件':
targets = [
self.position_word,
self.up_photo,
]
self.set_visibility(targets)
elif label.text() == '点击操作':
targets = [
self.comboBox, self.position_word,
self.shothoto, self.up_photo,
self.position_offset, self.x_word,
self.y_word, self.xposition, self.yposition,
self.times, self.delay_time
]
self.set_visibility(targets)
elif label.text() == '长按操作':
targets = [
self.comboBox, self.position_word,
self.shothoto, self.up_photo,
self.position_offset, self.x_word,
self.y_word, self.xposition, self.yposition,
self.times, self.delay_time
]
self.set_visibility(targets)
elif label.text() == '开始循环':
targets = [
]
self.set_visibility(targets)
elif label.text() == '输入操作':
targets = [
self.word
]
self.set_visibility(targets)
def setOperator(self, opt_text): # 获取到操作类型值
self.operator_text = opt_text
def getOperator(self): # 返回操作类型值
return self.operator_text
def set_visibility(self, targets=None):
# Set visibility of elements based on self.hide_elements
elements = [
self.delay_time, self.comboBox,
self.position_word, self.shothoto, self.up_photo,
self.word, self.position_offset, self.x_word,
self.y_word, self.xposition, self.yposition,
self.distence_word, self.distence, self.delay_time_word,
self.times
]
# elements = [
# self.click_position, self.delay_time, self.comboBox,
# self.position_word, self.shothoto, self.up_photo,
# self.word, self.position_offset, self.x_word,
# self.y_word, self.xposition, self.yposition,
# self.distence_word, self.distence, self.delay_time_word,
# self.times
# ]
for element in elements:
element.setVisible(False)
if targets is not None:
for element in targets:
element.setVisible(True)
# 操作函数---------------------------------------------
# 展示数据库条目
def create_userGeneralRule(self):
values = []
for input_box in self.inputs:
value = input_box.text()
values.append(value)
table_name = values[14]
db = DatabaseHandler(database='test2.sqlite3')
db.connect()
db.create_table(table_name)
db.insert_data('userGeneralRule', 0, table_name, 0, 0, 0, 0, 0, 0)
db.close()
def getrule(self):
values = []
for input_box in self.inputs:
value = input_box.text()
values.append(value)
table_name = values[9]
db = DatabaseHandler(database='test2.sqlite3')
db.connect()
db.cur.execute(f"SELECT * FROM {table_name}")
data = db.cur.fetchall()
display_text = ""
if table_name.startswith("gen"):
# 表示以 "gen" 开头
# 这里写下你的代码
for row in data:
text = f"序号: {row[0]}\n规则号: {row[1]}\n\n"
display_text += text
else:
for row in data:
text = f"序号: {row[0]}\n操作号: {row[1]}\n数据: {row[2:]}\n\n"
display_text += text
self.text_display.setText(display_text)
db.close()
def show_rules(self):
values = []
for input_box in self.inputs:
value = input_box.text()
values.append(value)
table_name = 'userConcreteRule'
db = DatabaseHandler(database='test2.sqlite3')
db.connect()
db.cur.execute(f"SELECT * FROM {table_name}")
data = db.cur.fetchall()
display_text = ""
for row in data:
text = f"序号: {row[0]}\n名称: {row[2]}\n\n"
display_text += text
self.text_display.setText(display_text)
db.close()
# db.cur.execute(f"SELECT MAX(pid) FROM {table_name}")
# max_pid = db.cur.fetchone()[0]
#
# print(max_pid)
#
# if max_pid is not None:
# id = 1
# while id < max_pid:
#
# db_data = db.execute_query(table_name, id)
# # 将元组数据转换为字符串
# text = f"ID: {db_data[0]}\nFilename: {db_data[1]}\nData: {db_data[2:]}"
# id = max_pid + 1
#
# self.text_display.setText(text)
# sleep(1)
#
# db.execute_query(table_name)
#
# db.close()
def startRule(self):
values = []
for input_box in self.inputs:
value = input_box.text()
values.append(value)
table_name = values[9]
db_control = DatabaseControl(database='test2.sqlite3')
db_control.perform_operations(table_name)
db_control.close()
def startGen(self):
values = []
for input_box in self.inputs:
value = input_box.text()
values.append(value)
gen_name = values[14]
db_control = DatabaseControl(database='test2.sqlite3')
db_control.perform_userGeneralRulename(gen_name)
db_control.close()
def getJpgInputs(self):
values = []
for input_box in self.inputs:
value = input_box.text()
values.append(value)
table_name = values[11]
id = values[13]
sc = ScreenCapture()
path = sc.capture_screen()
if path != None:
db = DatabaseHandler(database='test2.sqlite3')
db.connect()
db.insert_data(table_name, id, path, 0, 0, 0, 0, 0, 0)
db.execute_query(table_name)
db.close()
def getDelInputs(self):
values = []
for input_box in self.inputs:
value = input_box.text()
values.append(value)
table_name = values[9]
row = values[10]
db = DatabaseHandler(database='test2.sqlite3')
db.connect()
path = db.delete_row(table_name, row)
if path and len(path) > 0:
result = path[0][0]
print(result)
current_working_directory = os.getcwd() + '/res/pictures/' + result
print(current_working_directory)
operatation_select.delete_file(current_working_directory)
else:
print("No path found")
db.execute_query(table_name)
db.close()
def select_file(self):
file_path = filedialog.askopenfilename()
if not file_path.endswith(".exe"):
print("选择的文件不是以 .exe 结尾")
return
self.photo_name.setText(file_path)
# 在这里可以对选择的文件路径进行处理
print("选择的文件路径为:" + file_path)
def getInputs(self):
# table_name = self.rulename.toPlainText()
table_name = 'rule10'
path = '-'
xOffset = '-'
yOffset = '-'
pOffsetX = '-'
pOffsetY = '-'
time = '-'
rgb = '-'
label = self.selectedWidget.findChild(QLabel)
if label:
if label.text() == '延时操作':
id = 13
time = self.delay_time.text()
elif label.text() == '左滑操作':
id = 3
path = self.photo_name.text()
pOffsetX = self.xposition.text()
pOffsetY = self.yposition.text()
rgb = self.distence.text()
time = self.delay_time.text()
elif label.text() == '右滑操作':
id = 4
path = self.photo_name.text()
pOffsetX = self.xposition.text()
pOffsetY = self.yposition.text()
rgb = self.distence.text()
time = self.delay_time.text()
elif label.text() == '上滑操作':
id = 5
path = self.photo_name.text()
pOffsetX = self.xposition.text()
pOffsetY = self.yposition.text()
rgb = self.distence.text()
time = self.delay_time.text()
elif label.text() == '下滑操作':
id = 6
path = self.photo_name.text()
pOffsetX = self.xposition.text()
pOffsetY = self.yposition.text()
rgb = self.distence.text()
time = self.delay_time.text()
elif label.text() == '打开文件':
id = 15
path = self.photo_name.text()
elif label.text() == '点击操作':
id = 20 # 出现图片后点击
path = self.photo_name.text()
pOffsetX = self.xposition.text()
pOffsetY = self.yposition.text()
rgb = self.distence.text()
time = self.delay_time.text()
elif label.text() == '长按操作':
id = 2
pOffsetX = self.xposition.text()
pOffsetY = self.yposition.text()
rgb = self.distence.text()
time = self.delay_time.text()
elif label.text() == '开始循环':
id = 16
# path = values[2]
# xOffset = values[3]
# yOffset = values[4]
# pOffsetX = values[5]
# pOffsetY = values[6]
# time = values[7]
# rgb = values[8]
# pid = values[12]
values = [id, path, xOffset, yOffset, pOffsetX, pOffsetY, time, rgb]
self.last_window.set_word(values)
#
# db = DatabaseHandler(database='test2.sqlite3')
# db.connect()
# if pid == '':
# db.insert_data(table_name, id, path, xOffset, yOffset, pOffsetX, pOffsetY, time, rgb)
# else:
# pid = int(pid)
# db.insert_pidData(table_name, id, path, xOffset, yOffset, pOffsetX, pOffsetY, time, rgb, pid)
# db.execute_query(table_name)
# db.close()
# print('插入值:', values)
def create_table(self):
values = []
for input_box in self.inputs:
value = input_box.text()
values.append(value)
table_name = values[0]
db = DatabaseHandler(database='test2.sqlite3')
db.connect()
db.create_table(table_name)
db.close()
def del_table(self):
values = []
for input_box in self.inputs:
value = input_box.text()
values.append(value)
table_name = values[0]
db = DatabaseHandler(database='test2.sqlite3')
db.connect()
db.delete_table(table_name)
db.close()
def delete_file(file_path):
try:
if os.path.exists(file_path):
os.remove(file_path)
print(f"文件 {file_path} 已删除")
else:
print(f"文件 {file_path} 不存在")
except Exception as e:
print(f"删除文件时出现错误: {e}")
def write(self, text):
self.textEdit.moveCursor(QtGui.QTextCursor.End)
self.textEdit.insertPlainText(text)
def save_rules(self):
values = []
for input_box in self.inputs:
value = input_box.text()
values.append(value)
table_name = 'userConcreteRule'
path = values[0]
db = DatabaseHandler(database='test2.sqlite3')
db.connect()
db.insert_data(table_name, 0, path, 0, 0, 0, 0, 0, 0)
db.execute_query(table_name)
db.close()
print('保存表:', values[0])

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

@ -0,0 +1,91 @@
import pyautogui
import cv2
import numpy as np
from control.database.sqdatabase import *
import os
class ScreenCapture:
def __init__(self):
self.screen_width, self.screen_height = pyautogui.size()
self.rect_coordinates = []
self.flag = 0
def on_mouse(self, event, x, y, flags, param):
if event == cv2.EVENT_LBUTTONDOWN and self.flag == 0:
cv2.imshow("Capture", self.capture)
self.rect_coordinates = [(x, y)]
self.flag = 1
elif event == cv2.EVENT_MOUSEMOVE and (flags & cv2.EVENT_FLAG_LBUTTON):
capture_copy = self.capture.copy()
cv2.rectangle(capture_copy, self.rect_coordinates[0], (x, y), (0, 255, 0), 2)
cv2.imshow("Capture", capture_copy)
elif event == cv2.EVENT_LBUTTONUP:
self.rect_coordinates.append((x, y))
cv2.rectangle(self.capture, self.rect_coordinates[0], self.rect_coordinates[1], (0, 255, 0), 2)
cv2.imshow("Capture", self.capture)
elif event == cv2.EVENT_LBUTTONDOWN and self.flag == 1:
cv2.rectangle(self.capture, self.rect_coordinates[0], (x, y), (0, 255, 0), 2)
cv2.imshow("Capture", self.capture)
def capture_screen(self):
self.capture = pyautogui.screenshot()
self.capture = np.array(self.capture)
self.capture = cv2.cvtColor(self.capture, cv2.COLOR_RGB2BGR)
cv2.namedWindow("Capture", cv2.WINDOW_NORMAL)
cv2.setWindowProperty("Capture", cv2.WND_PROP_FULLSCREEN, cv2.WINDOW_FULLSCREEN)
cv2.setMouseCallback("Capture", self.on_mouse)
while True:
cv2.imshow("Capture", self.capture)
key = cv2.waitKey(1) & 0xFF
if key == 13:
if len(self.rect_coordinates) == 2:
x1, y1 = self.rect_coordinates[0]
x2, y2 = self.rect_coordinates[1]
if abs(x2 - x1) < 10 or abs(y2 - y1) < 10:
raise ValueError("x1, x2, y1, and y2 should have a difference greater than or equal to 10")
else:
#规范坐标
if x1>x2:
x = x1
x1 = x2
x2 = x
if y1>y2:
y = y1
y1 = y2
y2 = y
cropped_area = self.capture[min(y1 + 4, y2 - 4):max(y1 + 4, y2 - 4),
min(x1 + 4, x2 - 4):max(x1 + 4, x2 - 4)]
cv2.imshow("Cropped Area", cropped_area)
cv2.destroyAllWindows()
current_path = os.getcwd()
file_path = "cropped_area(%d,%d;%d,%d).png" % (x1, y1, x2, y2)
print(current_path+'/res/pictures/'+file_path)
cv2.imwrite(current_path+'/res/pictures/'+file_path, cropped_area)
#cv2.imwrite(current_path +'/'+ file_path, cropped_area)
print("截图已保存为%s" % file_path)
return file_path
else:
print("请先绘制矩形区域再按下'Enter'键进行截图!")
elif key == 27:
break
cv2.destroyAllWindows()

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 508 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

@ -0,0 +1,522 @@
import time
from windows.control.database.sqdatabase import DatabaseHandler, DatabaseDatum
from windows.entity.operations.endcondition import end_condition
from windows.entity.operations.operation import operation
import os
import keyboard
from windows.res.rules import 明日方舟换基建
from windows.res.rules import 明日方舟公开招募
from windows.res.rules import 明日方舟自动清体力
from windows.res.rules import 明日方舟日常处理
from windows.res.tools.deal_picture import DealPicture
global i
class DatabaseControl:
def __init__(self, database):
self.db = DatabaseHandler(database=database)
self.db.connect()
def execute_query(self, table_name, pid):
row = self.db.execute_query(table_name, pid)
return DatabaseDatum(*row)
def get_max_pid(self, table_name):
return self.db.get_max_pid(table_name)
def close(self):
self.db.close()
def rule_priority(self, ruleList):
for rule in ruleList:
self.perform_operations(rule)
# 注意:请确认
# while i<=ruleList:
# perform_operations(self, ruleList[i])
def perform_userGeneralRulename(self, gen_name):
j = 1
while j <= self.get_max_pid(gen_name):
# 根据gen寻找pid
datum = self.execute_query(gen_name, j)
pid = datum.id
# 根据pid寻找name
datu = self.execute_query('userConcreteRule', pid)
datum = datu.path
if datum == '返回终端界面':
明日方舟自动清体力.backToTerminal()
elif datum == '找到目标关卡':
明日方舟自动清体力.find_target_level()
elif datum == '找到目标章节':
明日方舟自动清体力.find_target_chapter()
elif datum == '战斗':
明日方舟自动清体力.fight_time()
elif datum == '回到基建界面':
明日方舟换基建.back_to_base()
elif datum == '进入基建界面':
明日方舟换基建.enter_base()
elif datum == '获得奖励':
明日方舟换基建.deal_award()
elif datum == '进入基建总览':
明日方舟换基建.enter_overview()
elif datum == '改变总览宿舍干员':
明日方舟换基建.change_dormitory_operators()
elif datum == '改变发电站干员':
明日方舟换基建.change_electricity_operators()
elif datum == '改变总览工作室干员':
明日方舟换基建.change_office_operators()
elif datum == '进入交易站':
明日方舟换基建.enter_trade_stations()
elif datum == '进入生产站':
明日方舟换基建.enter_product_stations()
elif datum == '到下一个工作室':
明日方舟换基建.to_next_station()
elif datum == '改变当前工作站干员':
明日方舟换基建.change_current_operators()
elif datum == '获取信用点':
明日方舟日常处理.visit_base()
elif datum == '消耗信用点':
明日方舟日常处理.credit_consume()
elif datum == '获得日常奖励':
明日方舟日常处理.acquire_award()
elif datum == '进入招募界面':
明日方舟公开招募.enter_recruit()
elif datum == '公开招募所有':
明日方舟公开招募.public_recruit_all()
elif datum == '公开招募一个':
明日方舟公开招募.public_recruit_one()
elif datum == '使用加急凭证':
明日方舟公开招募.use_ugent_recruit()
else:
self.perform_operations(datum)
j += 1
def perform_operations(self, table_name):
global runTime
global i
global startId
current_working_directory = os.getcwd() + '/res/pictures/'
print(current_working_directory)
flag = 0
if 'i' not in globals():
i = 1
if i > 9000:
flag = 1
i = 1
while (i <= self.get_max_pid(table_name)) or (flag == 1):
datum = self.execute_query(table_name, i)
r_value = datum.rgb
if r_value == '':
r_value = 0
else:
r_value = int(datum.rgb)
if datum.time == '':
datum.time = 1
if datum.id == 9:
operation.click_once1(current_working_directory + datum.path)
elif datum.id == 15:
operation.open_program(datum.path)
elif datum.id == 13:
print('延时开始')
for k in range(datum.time * 10):
operation.delay()
if keyboard.is_pressed('esc'):
i = 9999
break
print('延时结束')
elif datum.id == 1:
operation.click_fixed_point(datum.xOffset, datum.yOffset)
elif datum.id == 16:
startId = i
print(startId)
j = 0
# elif datum.id ==18:
elif datum.id == 17: # 次数作为结束条件
runTime = datum.time
if j < runTime:
j += 1
i = startId
elif datum.id == 18: # 图片出现作为结束条件
if operation.find_once(current_working_directory + datum.path) == 'true':
break
else:
i = startId
elif datum.id == 26:
if operation.find_once(current_working_directory + datum.path) != 'true':
break
else:
i = startId
elif datum.id == 27:
pos = operation.find_word_position(datum.path)
if pos is not None:
break
else:
i = startId
elif datum.id == 28:
pos = operation.find_word_position(datum.path)
if pos is None:
break
else:
i = startId
# elif datum.id == 20:
# while True:
# if operation.click_once1(current_working_directory + datum.path):
# break
# if keyboard.is_pressed('esc'):
# i = 9999
# break
elif datum.id == 21:
while True:
if operation.find_once(current_working_directory + datum.path):
break
if keyboard.is_pressed('esc'):
i = 9999
break
elif datum.id == 23:
while True:
if operation.find_word_position(datum.path):
break
if keyboard.is_pressed('esc'):
i = 9999
break
elif datum.id == 24:
while 1:
if not operation.find_word_position(datum.path):
break
if keyboard.is_pressed('esc'):
i = 9999
break
elif datum.id == 25:
first_photo = None
flag_25 = 0
while flag_25 == 0:
if first_photo is None:
first_photo = DealPicture.shot_photo(
{'left': datum.xOffset, 'top': datum.yOffset, 'width': datum.pOffsetX,
'height': datum.pOffsetY})
time.sleep(1)
current_photo = DealPicture.shot_photo(
{'left': datum.xOffset, 'top': datum.yOffset, 'width': datum.pOffsetX,
'height': datum.pOffsetY})
if end_condition.area_changed(first_photo, current_photo):
flag_25 = 1
print('匹配成功')
else:
print('匹配失败')
if keyboard.is_pressed('esc'):
i = 9999
break
elif datum.id == 30:
operation.keyin(datum.path)
elif datum.id == 91:
while True:
if operation.click_once(current_working_directory + datum.path, datum.pOffsetX, datum.pOffsetY):
break
if keyboard.is_pressed('esc'):
i = 9999
break
elif datum.id == 92:
while True:
pos = operation.find_word_position(datum.path)
if pos is not None:
operation.click_position_once(pos)
break
if keyboard.is_pressed('esc'):
i = 9999
break
time.sleep(1)
elif datum.id == 93:
path_array = datum.path.split(',') # 使用逗号作为分隔符
path_array = [int(x) for x in path_array]
operation.click_position_once(
{'left': path_array[0], 'top': path_array[1], 'width': path_array[2], 'height': path_array[3]})
i += 1
if keyboard.is_pressed('esc'):
i = 9999
elif datum.id == 31:
while True:
pos = operation.find_photo_position(current_working_directory + datum.path)
print(pos)
if pos is not None:
for q in range(datum.time):
operation.left_drag(pos, r_value, datum.pOffsetX, datum.pOffsetY)
if keyboard.is_pressed('esc'):
i = 9999
break
break
if keyboard.is_pressed('esc'):
i = 9999
break
time.sleep(1)
elif datum.id == 32:
while True:
pos = operation.find_word_position(datum.path)
if pos is not None:
for q in range(datum.time):
operation.left_drag(pos, r_value, datum.pOffsetX, datum.pOffsetY)
if keyboard.is_pressed('esc'):
i = 9999
break
break
if keyboard.is_pressed('esc'):
i = 9999
break
time.sleep(1)
elif datum.id == 33:
path_array = datum.path.split(',') # 使用逗号作为分隔符
path_array = [int(x) for x in path_array]
for q in range(datum.time):
operation.left_drag(
{'left': path_array[0], 'top': path_array[1], 'width': path_array[2], 'height': path_array[3]},
r_value, datum.pOffsetX, datum.pOffsetY)
if keyboard.is_pressed('esc'):
i = 9999
break
elif datum.id == 41:
while True:
pos = operation.find_photo_position(current_working_directory + datum.path)
print(pos)
if pos is not None:
for q in range(datum.time):
operation.right_drag(pos, r_value, datum.pOffsetX, datum.pOffsetY)
if keyboard.is_pressed('esc'):
i = 9999
break
break
if keyboard.is_pressed('esc'):
i = 9999
break
time.sleep(1)
elif datum.id == 42:
while True:
pos = operation.find_word_position(datum.path)
if pos is not None:
for q in range(datum.time):
operation.right_drag(pos, r_value, datum.pOffsetX, datum.pOffsetY)
if keyboard.is_pressed('esc'):
i = 9999
break
break
if keyboard.is_pressed('esc'):
i = 9999
break
time.sleep(1)
elif datum.id == 43:
path_array = datum.path.split(',') # 使用逗号作为分隔符
path_array = [int(x) for x in path_array]
for q in range(datum.time):
operation.right_drag(
{'left': path_array[0], 'top': path_array[1], 'width': path_array[2], 'height': path_array[3]},
r_value, datum.pOffsetX, datum.pOffsetY)
if keyboard.is_pressed('esc'):
i = 9999
break
elif datum.id == 51:
while True:
pos = operation.find_photo_position(current_working_directory + datum.path)
print(pos)
if pos is not None:
for q in range(datum.time):
operation.up_drag(pos, r_value, datum.pOffsetX, datum.pOffsetY)
if keyboard.is_pressed('esc'):
i = 9999
break
break
if keyboard.is_pressed('esc'):
i = 9999
break
time.sleep(1)
elif datum.id == 52:
while True:
pos = operation.find_word_position(datum.path)
if pos is not None:
for q in range(datum.time):
operation.up_drag(pos, r_value, datum.pOffsetX, datum.pOffsetY)
if keyboard.is_pressed('esc'):
i = 9999
break
break
if keyboard.is_pressed('esc'):
i = 9999
break
time.sleep(1)
elif datum.id == 53:
path_array = datum.path.split(',') # 使用逗号作为分隔符
path_array = [int(x) for x in path_array]
for q in range(datum.time):
operation.up_drag(
{'left': path_array[0], 'top': path_array[1], 'width': path_array[2], 'height': path_array[3]},
r_value, datum.pOffsetX, datum.pOffsetY)
if keyboard.is_pressed('esc'):
i = 9999
break
elif datum.id == 61:
while True:
pos = operation.find_photo_position(current_working_directory + datum.path)
print(pos)
if pos is not None:
for q in range(datum.time):
operation.down_drag(pos, r_value, datum.pOffsetX, datum.pOffsetY)
if keyboard.is_pressed('esc'):
i = 9999
break
break
if keyboard.is_pressed('esc'):
i = 9999
break
time.sleep(1)
elif datum.id == 62:
while True:
pos = operation.find_word_position(datum.path)
if pos is not None:
for q in range(datum.time):
operation.down_drag(pos, r_value, datum.pOffsetX, datum.pOffsetY)
if keyboard.is_pressed('esc'):
i = 9999
break
break
if keyboard.is_pressed('esc'):
i = 9999
break
time.sleep(1)
elif datum.id == 63:
path_array = datum.path.split(',') # 使用逗号作为分隔符
path_array = [int(x) for x in path_array]
for q in range(datum.time):
operation.down_drag(
{'left': path_array[0], 'top': path_array[1], 'width': path_array[2], 'height': path_array[3]},
r_value, datum.pOffsetX, datum.pOffsetY)
if keyboard.is_pressed('esc'):
i = 9999
break
elif datum.id == 71:
while True:
pos = operation.find_photo_position(current_working_directory + datum.path)
print(pos)
if pos is not None:
for q in range(datum.time):
operation.click_long(pos, datum.pOffsetX, datum.pOffsetY)
if keyboard.is_pressed('esc'):
i = 9999
break
break
if keyboard.is_pressed('esc'):
i = 9999
break
time.sleep(1)
elif datum.id == 72:
while True:
pos = operation.find_word_position(datum.path)
if pos is not None:
for q in range(datum.time):
operation.left_drag(pos, datum.pOffsetX, datum.pOffsetY)
if keyboard.is_pressed('esc'):
i = 9999
break
break
if keyboard.is_pressed('esc'):
i = 9999
break
time.sleep(1)
elif datum.id == 73:
path_array = datum.path.split(',') # 使用逗号作为分隔符
path_array = [int(x) for x in path_array]
for q in range(datum.time):
operation.left_drag(
{'left': path_array[0], 'top': path_array[1], 'width': path_array[2], 'height': path_array[3]},
datum.pOffsetX, datum.pOffsetY)
if keyboard.is_pressed('esc'):
i = 9999
break
#
# if __name__ == '__main__':
# db_control = DatabaseControl(database='test2.sqlite3')
#
# db_control.perform_userGeneralRulename('延时')
# db_control.close()

@ -0,0 +1,230 @@
import time
import cv2
import pyautogui as p
from windows.entity.operations.operation_first import operation_first
from windows.res.tools.deal_picture import DealPicture
from windows.res.tools.recognise_words import Recognise_word
p.PAUSE = 0.1
p.FAILSAFE = True
def backToTerminal():
print("back to terminal")
find_photo = cv2.imread('res/pictures/terminal_photo.png')
positions = DealPicture.find_photo_center(find_photo, 2)
while positions is None:
click_photo = cv2.imread('res/pictures/back_btn.png')
back_confirm = cv2.imread('res/pictures/back_confirm.png')
if DealPicture.find_photo_center(click_photo, 1):
operation_first.click_once(click_photo)
else:
return False
if DealPicture.find_photo_center(back_confirm, 1):
operation_first.click_once(back_confirm)
else:
return False
positions = DealPicture.find_photo_center('res/pictures/terminal_photo.png')
print("find terminal")
return True
# 19 进入招募界面
def enter_recruit():
print("enter_recruit")
find_photo = cv2.imread('res/pictures/in_recruit.png')
if DealPicture.find_photo_center(find_photo, 2):
print("in_recruit")
else:
if backToTerminal() is False:
return False
find_photo = cv2.imread('res/pictures/public_recruit.png')
stop_photo = cv2.imread('res/pictures/in_recruit.png')
DealPicture.find_photo_center(find_photo, 2)
if DealPicture.find_photo_center(find_photo, 2):
operation_first.click_util(find_photo, lambda: DealPicture.find_photo_center(stop_photo))
return True
return False
# 20 公开招募所有
def public_recruit_all():
print('现在在公开招募界面')
find_word = '开始招募干员'
find_photo = cv2.imread('res/pictures/in_recruit.png')
if DealPicture.find_photo_center(find_photo) is None:
return False
click_photo = cv2.imread('res/pictures/hire_operator.png')
stop_photo = cv2.imread('res/pictures/skip_word.png')
while DealPicture.find_photo_center(click_photo) is not None:
operation_first.click_util(click_photo, lambda: DealPicture.find_photo_center(stop_photo))
click_photo = cv2.imread('res/pictures/skip_word.png')
position = DealPicture.find_photo_position(click_photo)
if position is not None:
stop_photo = cv2.imread('res/pictures/in_recruit.png')
operation_first.click_position_util(position, lambda: DealPicture.find_photo_center(stop_photo))
else:
return False
shotphoto = p.screenshot()
words_inf = Recognise_word.recognise_word(shotphoto)
find_photo = cv2.imread('res/pictures/01times.png')
count_fail = 0
position = Recognise_word.find_word_positon(find_word, words_inf)
while position is not None:
operation_first.click_position_util(position, lambda: DealPicture.find_photo_center(find_photo))
position = DealPicture.find_photo_position(find_photo)
if position is not None:
stop_photo = cv2.imread('res/pictures/09times.png')
position['top'] += 70
operation_first.click_position_util(position, lambda: DealPicture.find_photo_center(stop_photo))
else:
return False
position_photo1 = cv2.imread('res/pictures/profession_need.png')
position_photo2 = cv2.imread('res/pictures/white_frame.png')
position1 = DealPicture.find_photo_position(position_photo1)
position2 = DealPicture.find_photo_position(position_photo2)
position = {}
if position1 is not None and position2 is not None:
position['left'] = position1['left'] + position1['width']
position['top'] = position1['top']
position['height'] = position1['height']
position['width'] = position2['left'] + position2['width'] - position['left']
if len(position) > 0:
shotphoto = DealPicture.shot_photo(position)
words = Recognise_word.recognise_word(shotphoto)
priority_list = DealPicture.class_recuit_priority(words)
if priority_list is None:
return True
word_positions = Recognise_word.find_words_positon(priority_list, words)
for word_postion in word_positions:
word_postion['left'] += position['left']
word_postion['top'] += position['top']
if priority_list is not None:
click_list(word_positions)
click_photo = cv2.imread('res/pictures/recruit_confirm.png')
if DealPicture.find_photo_center(click_photo):
operation_first.click_util(click_photo, lambda: DealPicture.find_no_photos([click_photo]))
time.sleep(1)
shotphoto = p.screenshot()
words_inf = Recognise_word.recognise_word(shotphoto)
position = Recognise_word.find_word_positon(find_word, words_inf)
else:
return False
return True
# 21 公开招募一个
def public_recruit_one():
try:
print('现在在公开招募界面')
find_word = '开始招募干员'
find_photo = cv2.imread('res/pictures/in_recruit.png')
if DealPicture.find_photo_center(find_photo) is None:
return False
click_photo = cv2.imread('res/pictures/hire_operator.png')
stop_photo = cv2.imread('res/pictures/skip_word.png')
while DealPicture.find_photo_center(click_photo) is not None:
operation_first.click_util(click_photo, lambda: DealPicture.find_photo_center(stop_photo))
click_photo = cv2.imread('res/pictures/skip_word.png')
position = DealPicture.find_photo_position(click_photo)
if position is not None:
stop_photo = cv2.imread('res/pictures/in_recruit.png')
operation_first.click_position_util(position, lambda: DealPicture.find_photo_center(stop_photo))
else:
return False
shotphoto = p.screenshot()
words_inf = Recognise_word.recognise_word(shotphoto)
find_photo = cv2.imread('res/pictures/01times.png')
position = Recognise_word.find_word_positon(find_word, words_inf)
if position is not None:
operation_first.click_position_util(position, lambda: DealPicture.find_photo_center(find_photo))
position = DealPicture.find_photo_position(find_photo)
if position is not None:
stop_photo = cv2.imread('res/pictures/09times.png')
position['top'] += 70
operation_first.click_position_util(position, lambda: DealPicture.find_photo_center(stop_photo))
else:
return False
position_photo1 = cv2.imread('res/pictures/profession_need.png')
position_photo2 = cv2.imread('res/pictures/white_frame.png')
position1 = DealPicture.find_photo_position(position_photo1)
position2 = DealPicture.find_photo_position(position_photo2)
position = {}
if position1 is not None and position2 is not None:
position['left'] = position1['left'] + position1['width']
position['top'] = position1['top']
position['height'] = position1['height']
position['width'] = position2['left'] + position2['width'] - position['left']
if len(position) > 0:
shotphoto = DealPicture.shot_photo(position)
words = Recognise_word.recognise_word(shotphoto)
priority_list = DealPicture.class_recuit_priority(words)
if priority_list is None:
return True
word_positions = Recognise_word.find_words_positon(priority_list, words)
for word_postion in word_positions:
word_postion['left'] += position['left']
word_postion['top'] += position['top']
if priority_list is not None:
click_list(word_positions)
click_photo = cv2.imread('res/pictures/recruit_confirm.png')
if DealPicture.find_photo_center(click_photo):
operation_first.click_util(click_photo, lambda: DealPicture.find_no_photos([click_photo]))
time.sleep(1)
else:
return False
except Exception as e:
# 处理其他类型的异常
print(f"Unexpected error: {e}")
return True
# 22 使用加急凭证
def use_ugent_recruit():
"""
使用加急凭证
"""
click_photo1 = cv2.imread('res/pictures/recruit_now.png')
stop_photo1 = cv2.imread('res/pictures/back_confirm.png')
while DealPicture.find_photo_center(click_photo1) is not None:
operation_first.click_util(click_photo1, lambda: DealPicture.find_photo_center(stop_photo1))
click_photo = cv2.imread('res/pictures/back_confirm.png')
stop_photo = cv2.imread('res/pictures/hire_operator.png')
operation_first.click_util(click_photo, lambda: DealPicture.find_photo_center(stop_photo))
click_photo = cv2.imread('res/pictures/hire_operator.png')
stop_photo = cv2.imread('res/pictures/skip_word.png')
operation_first.click_util(click_photo, lambda: DealPicture.find_photo_center(stop_photo))
click_photo = cv2.imread('res/pictures/skip_word.png')
position = DealPicture.find_photo_position(click_photo)
if position is not None:
stop_photo = cv2.imread('res/pictures/in_recruit.png')
operation_first.click_position_util(position, lambda: DealPicture.find_photo_center(stop_photo))
else:
return False
return True
def click_list(positions):
for position in positions:
operation_first.click_position_once(position)
def start_rule():
print('公开招募')
if enter_recruit() is False:
backToTerminal()
enter_recruit()
public_recruit_all()
backToTerminal()

File diff suppressed because it is too large Load Diff

@ -0,0 +1,149 @@
import cv2
import pyautogui as p
from windows.entity.operations.operation_first import operation_first
from windows.res.tools.deal_picture import DealPicture
p.PAUSE = 0.1
p.FAILSAFE = True
def backToTerminal():
print("back to terminal")
find_photo = cv2.imread('res/pictures/terminal_photo.png')
positions = DealPicture.find_photo_center(find_photo, 2)
while positions is None:
click_photo = cv2.imread('res/pictures/back_btn.png')
back_confirm = cv2.imread('res/pictures/back_confirm.png')
if DealPicture.find_photo_center(click_photo, 1):
operation_first.click_once(click_photo)
else:
return False
if DealPicture.find_photo_center(back_confirm, 1):
operation_first.click_once(back_confirm)
else:
return False
positions = DealPicture.find_photo_center('res/pictures/terminal_photo.png')
print("find terminal")
return True
# 16 获取信用点
def visit_base():
click_photo = cv2.imread('res/pictures/friends.png')
stop_photo = cv2.imread('res/pictures/friends_list.png')
positions = DealPicture.find_photo_center(click_photo, 1)
if positions is None:
backToTerminal()
positions = DealPicture.find_photo_center(click_photo, 1)
if positions is not None:
operation_first.click_util(click_photo, lambda: DealPicture.find_photo_center(stop_photo))
click_photo = cv2.imread('res/pictures/friends_list.png')
stop_photo = cv2.imread('res/pictures/visit_base.png')
positions = DealPicture.find_photo_center(click_photo, 1)
if positions is not None:
operation_first.click_util(click_photo, lambda: DealPicture.find_photo_center(stop_photo))
else:
return False
click_photo = cv2.imread('res/pictures/visit_base.png')
stop_photo = cv2.imread('res/pictures/visit_next.png')
positions = DealPicture.find_photo_center(click_photo, 1)
if positions is not None:
operation_first.click_util(click_photo, lambda: DealPicture.find_photo_center(stop_photo))
else:
return False
click_photo = cv2.imread('res/pictures/visit_next.png')
stop_photo = cv2.imread('res/pictures/communicate_limit.png')
positions = DealPicture.find_photo_center(click_photo, 1)
if positions is not None:
operation_first.click_util(click_photo, lambda: DealPicture.find_photo_center(stop_photo), 0, 0, 15)
else:
return False
backToTerminal()
return True
# 17 消耗信用点
def credit_consume():
click_photo = cv2.imread('res/pictures/shop.png')
stop_photo = cv2.imread('res/pictures/credit_deal.png')
positions = DealPicture.find_photo_center(click_photo, 1)
if positions is None:
backToTerminal()
positions = DealPicture.find_photo_center(click_photo, 1)
if positions is not None:
operation_first.click_util(click_photo, lambda: DealPicture.find_photo_center(stop_photo))
click_photo = cv2.imread('res/pictures/credit_deal.png')
stop_photo = [cv2.imread('res/pictures/in_credit_deal.png'), cv2.imread('res/pictures/unable_buy.png')]
positions = DealPicture.find_photo_center(click_photo, 1)
if positions is not None:
operation_first.click_util(click_photo, lambda: DealPicture.find_any_photos(stop_photo))
else:
return False
if DealPicture.find_photo_center(stop_photo[0]) is None:
backToTerminal()
return True
find_photo = cv2.imread('res/pictures/sale.png')
stop_photo = cv2.imread('res/pictures/buy.png')
stop_photo1 = cv2.imread('res/pictures/in_credit_deal.png')
positions = DealPicture.match_template_all(find_photo, 0.99)
for position in positions:
operation_first.click_position_util(position, lambda: DealPicture.find_photo_center(stop_photo))
buy_position = DealPicture.find_photo_position(stop_photo)
if buy_position is not None:
operation_first.click_position_util(buy_position, lambda: DealPicture.find_photo_center(stop_photo1))
else:
if DealPicture.find_photo_center(stop_photo1) is None:
find_photo1 = cv2.imread('res/pictures/back_btn.png')
if DealPicture.find_photo_center(find_photo1) is not None:
operation_first.click_once(find_photo1)
backToTerminal()
return True
# 18 获得日常奖励
def acquire_award():
click_photo = cv2.imread('res/pictures/mission.png')
stop_photo = cv2.imread('res/pictures/clicked_daily_mission.png')
positions = DealPicture.find_photo_center(click_photo, 1)
if positions is None:
backToTerminal()
positions = DealPicture.find_photo_center(click_photo, 1)
if positions is not None:
operation_first.click_util(click_photo, lambda: DealPicture.find_photo_center(stop_photo))
click_photo = cv2.imread('res/pictures/collect_all_award.png')
stop_photo = cv2.imread('res/pictures/unclicked_weekly_mission.png')
positions = DealPicture.find_photo_position(click_photo)
if positions is not None:
operation_first.click_position_util(positions, lambda: DealPicture.find_no_photos(click_photo))
operation_first.click_position_util(positions, lambda: DealPicture.find_photo_center(stop_photo))
click_photo = cv2.imread('res/pictures/unclicked_weekly_mission.png')
stop_photo = cv2.imread('res/pictures/clicked_weekly_mission.png')
if click_photo is not None:
operation_first.click_util(click_photo, lambda: DealPicture.find_photo_center(stop_photo))
click_photo = cv2.imread('res/pictures/collect_all_award.png')
stop_photo = cv2.imread('res/pictures/clicked_weekly_mission.png')
positions = DealPicture.find_photo_position(click_photo)
if positions is not None:
operation_first.click_position_util(positions, lambda: DealPicture.find_no_photos(click_photo))
operation_first.click_position_util(positions, lambda: DealPicture.find_photo_center(stop_photo))
backToTerminal()
return True
def start_rule():
print('日常处理')
if visit_base() is False:
backToTerminal()
visit_base()
backToTerminal()
credit_consume()
backToTerminal()

@ -1,17 +1,16 @@
import time
import cv2
import pyautogui as p
from PyQt5.QtCore import QThread, pyqtSignal
from windows.entity.operations.operation import operation
from windows.entity.operations.operation_first import operation_first
from windows.res.tools.deal_picture import DealPicture
p.PAUSE = 0.1
p.FAILSAFE = True
# 01 返回终端界面
def backToTerminal():
print("back to terminal")
positions = DealPicture.find_photo_center('res/pictures/terminal_photo.png', 2)
@ -19,11 +18,11 @@ def backToTerminal():
click_photo = cv2.imread('res/pictures/back_btn.png')
back_confirm = cv2.imread('res/pictures/back_confirm.png')
if DealPicture.find_photo_center(click_photo, 1):
operation.click_once(click_photo)
operation_first.click_once(click_photo)
else:
return False
if DealPicture.find_photo_center(back_confirm, 1):
operation.click_once(back_confirm)
operation_first.click_once(back_confirm)
else:
return False
positions = DealPicture.find_photo_center('res/pictures/terminal_photo.png')
@ -31,6 +30,7 @@ def backToTerminal():
return True
# 02 找到目标关卡
def find_target_level():
print("finding level")
@ -46,7 +46,7 @@ def find_target_level():
drag_position = cv2.imread('res/pictures/back_btn.png')
name = 'level_1-7.png'
if DealPicture.find_photo_center('res/pictures/back_btn.png', 2):
operation.drag_once(drag_position, 300, 0, 0, 200)
operation_first.drag_once(drag_position, 300, 0, 0, 200)
else:
print("don't find picture ", name)
return False
@ -54,7 +54,7 @@ def find_target_level():
while DealPicture.find_photo_center('res/pictures/level_1-7.png', 1, 0.9) is None:
drag_position = cv2.imread('res/pictures/back_btn.png')
if DealPicture.find_photo_center('res/pictures/back_btn.png', 2):
operation.drag_once(drag_position, -400, 0, 300, 200)
operation_first.drag_once(drag_position, -400, 0, 300, 200)
else:
print("back to terminal")
return False
@ -63,20 +63,21 @@ def find_target_level():
stop_photo = [cv2.imread('res/pictures/fight_photo.png')]
name = 'level_1-7.png'
if DealPicture.find_photo_center(click_photo, 1, 0.9):
operation.click_util(click_photo, lambda: DealPicture.find_any_photos(stop_photo))
operation_first.click_util(click_photo, lambda: DealPicture.find_any_photos(stop_photo))
else:
print("don't find picture", name)
return False
return True
# 03 找到目标章节
def find_target_chapter():
print("finding chapter")
click_photo = cv2.imread('res/pictures/terminal_photo.png')
stop_photo = [cv2.imread('res/pictures/theme_word.png'), cv2.imread('res/pictures/theme_word2.png')]
name = 'terminal_photo.png'
if DealPicture.find_photo_center(click_photo, 1):
operation.click_util(click_photo, lambda: DealPicture.find_any_photos(stop_photo))
operation_first.click_util(click_photo, lambda: DealPicture.find_any_photos(stop_photo))
else:
print("don't find picture", name)
return False
@ -85,7 +86,7 @@ def find_target_chapter():
stop_photo = [cv2.imread('res/pictures/black_circle.png')]
name = 'theme_word.png'
if DealPicture.find_photo_center(click_photo, 1):
operation.click_util(click_photo, lambda: DealPicture.find_any_photos(stop_photo))
operation_first.click_util(click_photo, lambda: DealPicture.find_any_photos(stop_photo))
else:
print("don't find picture", name)
return False
@ -94,7 +95,7 @@ def find_target_chapter():
stop_photo = [cv2.imread('res/pictures/purpose_chapter.png')]
name = 'black_circle.png'
if DealPicture.find_photo_center(drag_position, 1):
operation.drag_util(drag_position, lambda: DealPicture.find_any_photos(stop_photo), 0, 400)
operation_first.drag_util(drag_position, lambda: DealPicture.find_any_photos(stop_photo), 0, 400)
else:
print("don't find picture", name)
return False
@ -103,7 +104,7 @@ def find_target_chapter():
stop_photo = [cv2.imread('res/pictures/chapter2.png')]
name = 'chapter3.png'
if DealPicture.find_photo_center(drag_position, 1):
operation.drag_util(drag_position, lambda: DealPicture.find_any_photos(stop_photo), 300, 0)
operation_first.drag_util(drag_position, lambda: DealPicture.find_any_photos(stop_photo), 300, 0)
else:
print("don't find picture", name)
return False
@ -112,7 +113,7 @@ def find_target_chapter():
stop_photo = [cv2.imread('res/pictures/chapter1.png')]
name = 'chapter2.png'
if DealPicture.find_photo_center(drag_position, 1):
operation.drag_util(drag_position, lambda: DealPicture.find_any_photos(stop_photo), 300, 0)
operation_first.drag_util(drag_position, lambda: DealPicture.find_any_photos(stop_photo), 300, 0)
else:
print("don't find picture", name)
return False
@ -121,7 +122,7 @@ def find_target_chapter():
stop_photos = [cv2.imread('res/pictures/fight_photo.png'), cv2.imread('res/pictures/cur_chapter1.png')]
name = 'chapter1.png'
if DealPicture.find_photo_center(click_photo, 1):
operation.click_util(click_photo, lambda: DealPicture.find_any_photos(stop_photos))
operation_first.click_util(click_photo, lambda: DealPicture.find_any_photos(stop_photos))
else:
print("don't find picture", name)
return False
@ -129,13 +130,14 @@ def find_target_chapter():
return True
# 04 战斗
def fight_time():
print("fighting time!")
click_photo = cv2.imread('res/pictures/fight_photo.png')
stop_photo = [cv2.imread('res/pictures/start_fighting.png')]
name = 'fight_photo.png'
if DealPicture.find_photo_center(click_photo, 1):
operation.click_util(click_photo, lambda: DealPicture.find_any_photos(stop_photo))
operation_first.click_util(click_photo, lambda: DealPicture.find_any_photos(stop_photo))
else:
print("don't find picture", name)
return False
@ -144,7 +146,7 @@ def fight_time():
stop_photo = [cv2.imread('res/pictures/fighting!.png')]
name = 'start_fighting!.png'
if DealPicture.find_photo_center(click_photo, 2):
operation.click_util(click_photo, lambda: DealPicture.find_any_photos(stop_photo))
operation_first.click_util(click_photo, lambda: DealPicture.find_any_photos(stop_photo))
else:
print("don't find picture", name)
return False
@ -157,13 +159,13 @@ def fight_time():
click_photo = cv2.imread('res/pictures/mission_fail.png')
stop_photo = [cv2.imread('res/pictures/mission_complete.png')]
if DealPicture.find_photo_center(click_photo, 5):
operation.click_util(click_photo, lambda: DealPicture.find_any_photos(stop_photo))
operation_first.click_util(click_photo, lambda: DealPicture.find_any_photos(stop_photo))
click_photo = cv2.imread('res/pictures/mission_complete.png')
stop_photo = [cv2.imread('res/pictures/fight_photo.png')]
name = 'mission_complete.png'
if DealPicture.find_photo_center(click_photo, 5):
operation.click_util(click_photo, lambda: DealPicture.find_any_photos(stop_photo))
operation_first.click_util(click_photo, lambda: DealPicture.find_any_photos(stop_photo))
else:
print("don't find picture", name)
return False
@ -171,24 +173,40 @@ def fight_time():
return True
class WorkerThread(QThread):
finished = pyqtSignal()
def run(self):
i = 0
if find_target_level():
while i < 10:
fight_time()
else:
backToTerminal()
while fight_time() is False:
while find_target_level() is False:
while find_target_chapter() is False:
while backToTerminal() is False:
print("开始")
i += 1
def start_rule():
print('清体力')
i = 0
if find_target_level():
# if self.stop is True:
# return
while i < 10:
fight_time()
i += 1
print("自动战斗完毕")
self.finished.emit()
# if self.stop is True:
# return
else:
# if self.stop is True:
# return
backToTerminal()
# if self.stop is True:
# return
while fight_time() is False:
# if self.stop is True:
# return
while find_target_level() is False:
# if self.stop is True:
# return
while find_target_chapter() is False:
# if self.stop is True:
# return
while backToTerminal() is False:
# if self.stop is True:
# return
print("开始")
i += 1
while i < 15:
fight_time()
# if self.stop is True:
# return
i += 1
print("自动战斗完毕")

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save