pcacc 8 mesiacov pred
rodič
commit
333385378f

+ 0 - 3
.gitmodules

@@ -1,3 +0,0 @@
-[submodule "scriptBase"]
-	path = scriptBase
-	url = http://192.168.50.102:3000/pcacc/scriptBase

+ 1 - 0
scriptBase/.gitignore

@@ -0,0 +1 @@
+*.pyc

+ 20 - 0
scriptBase/base.py

@@ -0,0 +1,20 @@
+import builtins
+import datetime
+
+# 保存原始的 print 函数
+original_print = print
+
+# 定义自定义的输出函数
+def custom_print(*args, **kwargs):
+    # 获取当前时间
+    current_time = datetime.datetime.now()
+    # 添加时间前缀
+    prefix = f"[{current_time}]"
+    # 将时间前缀与要打印的内容拼接
+    modified_args = (prefix,) + args
+    # 调用原始的 print 函数打印内容
+    original_print(*modified_args, **kwargs)
+
+# 替换内置的 print 函数为自定义的输出函数
+builtins.print = custom_print
+

+ 273 - 0
scriptBase/comon.py

@@ -0,0 +1,273 @@
+# -*- coding: utf-8 -*-
+from scriptBase.imgFind import pcacc_img
+from scriptBase.mouseClick import pcacc_mouse
+import time
+import random
+import pygetwindow as gw
+import re
+from PIL import Image
+import io
+
+def compress_image(image, target_size = 100 * 1024):
+    # 调整图像尺寸,保持纵横比
+    image.thumbnail((1024, 1024))
+
+    # 尝试不同的压缩质量
+    quality = 80
+    compressed_image = io.BytesIO()
+    while compressed_image.tell() < target_size and quality >= 10:
+        image.save(compressed_image, format='JPEG', quality=quality)
+        quality -= 10
+        compressed_image.seek(0)
+        compressed_size = len(compressed_image.getvalue())
+
+    return compressed_image.getvalue()
+
+def binarize_image(image):
+    # 将图片转换为黑白格式(二值化)
+    # 这里使用Pillow库来进行图片二值化
+    image = image.convert("L")  # 将图片转换为灰度图像
+    threshold = 128  # 设定二值化阈值,0~255之间,通常取128
+    image = image.point(lambda x: 0 if x < threshold else 255, '1')  # 进行二值化处理
+    return image
+
+
+
+def waitFindImg(imgPath, waitTime, preWaitTime):
+    if preWaitTime > 0:
+        myTimeSleep(preWaitTime)
+    #sleep 0.2s per times
+    curTime = 0
+    while waitTime == -1 or curTime < waitTime:
+        ret, pos_cur = pcacc_img.find_imgs(imgPath)
+        if ret:
+            return ret, pos_cur
+        else:
+            myTimeSleep(0.2)
+            curTime = curTime + 0.2
+    
+    return False, None
+
+def waitFindImg_withBool(imgPath, waitTime, preWaitTime):
+    ret, pos = waitFindImg(imgPath, waitTime, preWaitTime)
+    return ret
+
+def waitFindImgPosition(imgPath, waitTime, preWaitTime):
+    if preWaitTime > 0:
+        myTimeSleep(preWaitTime)
+    #sleep 0.2s per times
+    curTime = 0
+    while waitTime == -1 or curTime < waitTime:
+        ret, pos_cur = pcacc_img.find_img_position(imgPath)
+        if ret:
+            return ret, pos_cur
+        else:
+            myTimeSleep(0.2)
+            curTime = curTime + 0.2
+    return False, None
+
+def waitFindImgPosition_withBool(imgPath, waitTime, preWaitTime):
+    ret, pos = waitFindImgPosition(imgPath, waitTime, preWaitTime)
+    return ret
+
+def waitClickImg_noWait(imgPath, waitTime, preWaitTime):
+    if preWaitTime > 0:
+        myTimeSleep(preWaitTime)
+    #sleep 0.2s per times
+    curTime = 0
+    while waitTime == -1 or curTime < waitTime:
+        ret, pos_cur = pcacc_img.find_imgs(imgPath)
+        if ret:
+            pcacc_mouse.click(pos_cur[0], pos_cur[1])
+            myTimeSleep(0.5)
+            return True, pos_cur
+        else:
+            myTimeSleep(0.2)
+            curTime = curTime + 0.2
+    return False, (-1, -1)
+
+def waitClickImg_noWait_withBool(imgPath, waitTime, preWaitTime):
+    ret, pos = waitClickImg_noWait(imgPath, waitTime, preWaitTime)
+    return ret
+
+
+def waitclickMultiImg(imgArr, waitTime, preWaitTime):
+    if preWaitTime > 0:
+        myTimeSleep(preWaitTime)
+    #sleep 0.2s per times
+    curTime = 0
+    while waitTime == -1 or curTime < waitTime:
+        ret, pos_cur = pcacc_img.find_imgArr(imgArr)
+        if ret:
+            pcacc_mouse.click(pos_cur[0], pos_cur[1])
+            myTimeSleep(0.5)
+            ret, pos_cur = pcacc_img.find_imgArr(imgArr)
+            if ret == False:
+                return True, pos_cur
+            pcacc_mouse.click(pos_cur[0], pos_cur[1])
+            myTimeSleep(0.5)
+            ret, pos_cur = pcacc_img.find_imgArr(imgArr)
+            if ret == False:
+                return True, pos_cur
+            else:
+                return True, pos_cur
+        else:
+            myTimeSleep(0.2)
+            curTime = curTime + 0.2
+    return False, (-1, -1)
+
+
+def waitClickImg(imgPath, waitTime, preWaitTime):
+    if preWaitTime > 0:
+        myTimeSleep(preWaitTime)
+    #sleep 0.2s per times
+    curTime = 0
+    while waitTime == -1 or curTime < waitTime:
+        ret, pos_cur = pcacc_img.find_imgs(imgPath)
+        if ret:
+            pcacc_mouse.move_mouse(pos_cur[0], pos_cur[1])
+            ret, pos_cur2 = pcacc_img.find_imgs(imgPath)
+            if ret:
+                pcacc_mouse.click(pos_cur2[0], pos_cur2[1])
+            else:
+                pcacc_mouse.click(pos_cur[0], pos_cur[1])
+            myTimeSleep(0.5)
+            ret, pos_cur = pcacc_img.find_imgs(imgPath)
+            if ret == False:
+                return True, pos_cur
+            
+            pcacc_mouse.move_mouse(pos_cur[0], pos_cur[1])
+            ret, pos_cur2 = pcacc_img.find_imgs(imgPath)
+            if ret:
+                pcacc_mouse.click(pos_cur2[0], pos_cur2[1])
+            else:
+                pcacc_mouse.click(pos_cur[0], pos_cur[1])
+
+            myTimeSleep(0.5)
+            ret, pos_cur = pcacc_img.find_imgs(imgPath)
+            if ret == False:
+                return True, pos_cur
+            else:
+                return True, pos_cur
+        else:
+            myTimeSleep(0.2)
+            curTime = curTime + 0.2
+    return False, (-1, -1)
+
+def waitClickImg_withBool(imgPath, waitTime, preWaitTime):
+    ret, pos = waitClickImg(imgPath, waitTime, preWaitTime)
+    return ret
+
+def myTimeSleep(curTime):
+    tmpTime = curTime * 1000
+    randomTime = random.randint(int(tmpTime - tmpTime / 9), int(tmpTime + tmpTime / 9)) / 1000
+    while randomTime > 30:
+        time.sleep(30)
+        randomTime -= 30
+        print(f'剩余等待时间{randomTime}')
+    time.sleep(randomTime)
+
+def myTimeSleep_small():
+    time.sleep(random.randint(200, 1000) / 1000)
+
+def myTimeSleep_big():
+    time.sleep(random.randint(1200, 2000) / 1000)
+
+def get_random_point(region):
+    left, top, width, height = region
+    x = random.randint(left, left + width)
+    y = random.randint(top, top + height)
+    return x, y
+
+def get_yys_random_point(region):
+    dstRegion = yys_getRegion(region, True)
+    return get_random_point(dstRegion)
+
+
+def maintain_state(min):
+    state = True
+    last_reset_time = time.time()
+
+    def inner_func():
+        nonlocal state, last_reset_time
+
+        # 获取当前时间
+        current_time = time.time()
+
+        # 如果距离上次重置的时间大于等于min秒,则将状态重置为True
+        if current_time - last_reset_time >= min:
+            state = True
+            last_reset_time = current_time
+
+        # 返回状态值,并将状态置为False
+        result = state
+        state = False
+        return result
+
+    return inner_func
+
+def find_window_pos(title):
+    # 查找窗口
+    winList = gw.getWindowsWithTitle(title)
+    if len(winList) == 0:
+        return False, None
+    window = gw.getWindowsWithTitle(title)[0]  # 替换为你要查找的窗口标题
+
+    # 获取位置信息
+    left = window.left
+    top = window.top
+    width = window.width
+    height = window.height
+
+    # 打印位置信息
+    print(f'Left: {left}, Top: {top}, Width: {width}, Height: {height}')
+    if left > 0 and top > 0 and width > 0 and height > 0:
+        return True, (left, top, width, height)
+    else:
+        return False, None
+
+def find_yys_pos():
+    return find_window_pos('Mumu模拟器12')
+
+def get_first_single_digit(string):
+    pattern = r'\d'  # 匹配一个独立的单个数字
+    match = re.search(pattern, string)
+    if match:
+        return int(match.group())  # 将匹配到的字符串转换为整数
+    else:
+        return None
+
+def dragAuto(gamestr, positions):
+    tmpRet, tmpPos = find_window_pos(gamestr)
+    if tmpRet == False:
+        return False
+    
+    x1 = positions[0] + tmpPos[0] + random.randint(-20, 20)
+    y1 = positions[1] + tmpPos[1] + random.randint(-20, 20)
+    x2 = positions[2] + tmpPos[0] + random.randint(-20, 20)
+    y2 = positions[3] + tmpPos[1] + random.randint(-20, 20)
+    pcacc_mouse.drag_from(x1, y1, x2, y2)
+    return True
+
+def yys_dragAuto(positions):
+    return dragAuto('Mumu模拟器12', positions)
+
+def getRegion(gamestr, region, isWidth):
+    tmpRet, tmpPos = find_window_pos(gamestr)
+    if tmpRet == False:
+        return False
+    if isWidth:
+        return (region[0] + tmpPos[0], region[1] + tmpPos[1], region[2], region[3])
+    else:
+        return (region[0] + tmpPos[0], region[1] + tmpPos[1], region[2] + tmpPos[0], region[3] + tmpPos[1])
+
+
+def yys_getRegion(region, isWidth= False):
+    return getRegion('Mumu模拟器12', region, isWidth)
+
+def click_waitimg(pos_x,pos_y,img):
+    retry_times = 3
+    while  retry_times > 0 and waitFindImg_withBool(img,0.4,1) == False:
+        pcacc_mouse.click(pos_x,pos_y)
+        retry_times-=1
+    return retry_times > 0

+ 77 - 0
scriptBase/doOtherThing.py

@@ -0,0 +1,77 @@
+# -*- coding: utf-8 -*-
+from scriptBase.imgFind import pcacc_img
+from scriptBase.mouseClick import pcacc_mouse
+import scriptBase.comon as comon
+import subprocess
+import pyautogui
+import random
+import string
+import time
+import pygetwindow as gw
+
+pic_notepad = 'other\other_notepad.png'
+pic_calc = 'other\other_calc.png'
+pic_edge = 'other\other_edge.png'
+
+# 生成随机字符串
+def generate_random_string(length):
+    letters = string.ascii_letters + string.digits  # 包含字母和数字的字符集
+    return ''.join(random.choice(letters) for _ in range(length))
+
+def typeRandomStr(str):
+    random_string = str
+    if len(random_string) == 0:
+        random_string = generate_random_string(random.randint(50, 100))
+    for char in random_string:
+        pyautogui.typewrite(char)
+        delay = random.uniform(0.1, 0.3)  # 生成随机延迟时间
+        time.sleep(delay)
+
+class doOtherThing:
+    @staticmethod
+    def doWithNotePad():
+        app_path = "notepad.exe"
+        subprocess.Popen(app_path)
+        comon.myTimeSleep_big()
+        ret, position = pcacc_img.find_img_position(pic_notepad)
+        if ret:
+            point1, point2 = pcacc_img.choose_two_point_from_position(position)
+            pcacc_mouse.click(point1[0], point1[1])
+            comon.myTimeSleep_small()
+            typeRandomStr('')
+            pyautogui.scroll(random.randint(-20, 20))
+            pcacc_mouse.drag(point2[0], point2[1])
+            comon.myTimeSleep_big()
+
+        subprocess.call(f"taskkill /f /im {app_path}")
+
+    @staticmethod
+    def doWithCalc():
+        app_path = "calc.exe"
+        subprocess.Popen(app_path)
+        comon.myTimeSleep_big()
+        if comon.waitClickImg_noWait(pic_calc, 1, 0):
+            comon.myTimeSleep_big()
+            operators = ['+', '-', '*', '/']
+            random_str = str(random.randint(100, 200)) + random.choice(operators) + str(random.randint(100, 200)) + random.choice(operators)
+            typeRandomStr(random_str)
+            comon.myTimeSleep_big()
+
+        subprocess.call(f"taskkill /f /im CalculatorApp.exe")
+
+    @staticmethod
+    def doWithEdge():
+        if comon.waitClickImg_noWait(pic_edge, 2, 0):
+                comon.myTimeSleep_big()
+                pyautogui.scroll(random.randint(-20, 20))
+                comon.myTimeSleep(60)
+                pyautogui.scroll(random.randint(-20, 20))
+                comon.myTimeSleep(60)
+                comon.waitClickImg_noWait(pic_edge, 2, 0)
+        
+
+    OtherThingFuncArr = [doWithNotePad, doWithCalc]
+
+
+if __name__ == '__main__':
+    doOtherThing.doWithEdge()

+ 225 - 0
scriptBase/imgFind.py

@@ -0,0 +1,225 @@
+# -*- coding: utf-8 -*-
+import pyautogui
+import random
+import time
+import numpy as np
+import cv2
+from PIL import Image
+import pyscreeze
+
+pyscreeze.USE_IMAGE_NOT_FOUND_EXCEPTION = False
+
+
+def color_string_to_rgb(color_string):
+    r = int(color_string[0:2], 16)
+    g = int(color_string[2:4], 16)
+    b = int(color_string[4:6], 16)
+    return (r, g, b)
+
+def savePic(screenshot, fileName):
+    image = Image.frombytes('RGB', screenshot.size, screenshot.bgra, 'raw', 'BGRX')
+    image.save(fileName)  # 保存为PNG格式的图像文件
+
+def find_center_point(pointArr):
+    min_distance = float('inf')
+    center_point = None
+
+    for point in pointArr:
+        total_distance = 0
+        for other_point in pointArr:
+            distance = ((other_point[0] - point[0]) ** 2 + (other_point[1] - point[1]) ** 2) ** 0.5
+            total_distance += distance
+
+        if total_distance < min_distance:
+            min_distance = total_distance
+            center_point = point
+
+    return center_point
+
+class pcacc_img:
+    def __init__(specifically):
+        random.seed()
+    
+    @staticmethod
+    def find_maxColor_position(cur_region, colorArr): #(left, top, width, height)
+        left = cur_region[0]
+        top = cur_region[1]
+        width = cur_region[2]
+        height = cur_region[3]
+        region = (left, top, width, height)
+        # 目标颜色和容差值
+         
+        tolerance = 10  # 容差值
+
+        # 在指定区域获取屏幕图像
+        screenshotSrc = pyautogui.screenshot(region=region)
+        print(region)
+        
+        
+        screenshot = np.array(screenshotSrc)
+        dstPointArr = []
+
+        # 创建颜色范围的上下界
+        for color_str in colorArr:
+            target_color = color_string_to_rgb(color_str)
+            lower_color = np.array(target_color) - tolerance
+            upper_color = np.array(target_color) + tolerance
+
+            # 在图像中查找匹配的像素
+            mask = cv2.inRange(screenshot, lower_color, upper_color)
+            # 显示 mask 图像
+            #plt.imshow(mask, cmap='gray')
+            #plt.show()
+            points = np.transpose(np.where(mask > 0))
+
+            if len(points) < 5:
+                continue
+
+            # 转换坐标到全局坐标系
+            points[:, 0] += region[0]
+            points[:, 1] += region[1]   
+            '''
+            # 使用K-means聚类将匹配点分为不同的簇
+            n_clusters = 5  # 簇的数量,可根据需要进行调整
+            kmeans = KMeans(n_clusters=n_clusters)
+            kmeans.fit(points)
+
+            # 找到最大的簇
+            max_cluster_label = np.argmax(np.bincount(kmeans.labels_))
+            max_cluster_points = points[kmeans.labels_ == max_cluster_label]
+            '''
+            # 输出最集中的像素区域的位置
+            for point in points:
+                dstPointArr.append(point)
+
+        if len(dstPointArr) > 0:
+            return True, find_center_point(dstPointArr)
+        else:
+            return False, (-1, -1)
+    
+
+
+
+    @staticmethod
+    def find_img_position(image_path):
+        # 设置查找的置信度(confidence)阈值,范围从0到1,默认为0.999
+        confidence_threshold = 0.90
+
+        # 查找模糊图片在屏幕上的位置
+        position = pyautogui.locateOnScreen(image_path, confidence=confidence_threshold)
+
+        if position is not None:
+            return True, position
+        else:
+            return False, None
+        
+    @staticmethod
+    def choose_two_point_from_position(position):
+        dst_x1 = random.randint(position.left, position.left + position.width)
+        dst_y1 = random.randint(position.top, position.top + position.height)
+
+        dst_x2 = random.randint(position.left, position.left + position.width)
+        dst_y2 = random.randint(position.top, position.top + position.height)
+
+        return (dst_x1, dst_y1), (dst_x2, dst_y2)
+
+    @staticmethod
+    def choose_one_point_from_position(position):
+        dst_x1 = random.randint(position.left, position.left + position.width)
+        dst_y1 = random.randint(position.top, position.top + position.height)
+        return (dst_x1, dst_y1)
+
+    @staticmethod
+    def find_all_img(image_path):
+
+        # 设置查找的置信度(confidence)阈值,范围从0到1,默认为0.999
+        confidence_threshold = 0.85
+
+        # 查找模糊图片在屏幕上的位置
+        positions = pyautogui.locateAllOnScreen(image_path, confidence=confidence_threshold)
+
+        if len(positions) == 0:
+            return False, []
+
+        return True, positions
+
+    @staticmethod
+    def find_img(image_path):
+
+        # 设置查找的置信度(confidence)阈值,范围从0到1,默认为0.999
+        confidence_threshold = 0.85
+
+        # 查找模糊图片在屏幕上的位置
+        position = pyautogui.locateOnScreen(image_path, confidence=confidence_threshold)
+
+        if position is not None:
+            # 图片找到了,获取图片的中心点坐标
+
+            #mid
+            mid_left = int(position.left + position.width / 4)
+            mid_right = int(position.left + position.width / 4 * 3)
+            mid_top = int(position.top + position.height / 4)
+            mid_bottom = int(position.top + position.height / 4 * 3)
+
+            #want_position
+            want_x = random.randint(mid_left, mid_right)
+            want_y = random.randint(mid_top, mid_bottom)
+
+            #dst_position
+            dst_x = random.randint(int(want_x - position.width / 3), int(want_x + position.width / 3))
+            dst_y = random.randint(int(want_y - position.height / 3), int(want_y + position.height / 3))
+            
+
+            print(f"{image_path}:({dst_x}, {dst_y})")
+            return True, (dst_x, dst_y)
+        else:
+            print(f"{image_path}图片未找到")
+            return False, (-1, -1)
+
+    @staticmethod
+    def find_imgArr(imgArr):
+        for cur_img in imgArr:
+            ret, pos = pcacc_img.find_img(cur_img)
+            if ret:
+                return ret, pos
+        return False, None
+
+    @staticmethod
+    def find_imgs(images):
+        if isinstance(images, str):
+            return pcacc_img.find_img(images)
+        elif isinstance(images, (list, tuple)):
+            return pcacc_img.find_imgArr(images)
+        else:
+            raise ValueError("Invalid input type for 'images' parameter.")
+
+    @staticmethod
+    def find_all_image_locations(image):
+        confidence_threshold = 0.95
+        # 查找所有符合条件的图片位置
+        locations = pyautogui.locateAllOnScreen(image, confidence=confidence_threshold)
+
+        # 将位置信息保存到列表中
+        image_locations = []
+        for location in locations:
+            # 获取位置信息的左上角坐标和宽高
+            x, y, width, height = location
+            # 将位置信息添加到列表中
+            image_locations.append((x, y, width, height))
+
+        return image_locations
+    @staticmethod
+    def find_img_in_area(image,region=None):
+        confidence_threshold = 0.85
+        location = pyautogui.locateOnScreen(image,region=region, confidence=confidence_threshold)
+        if location is not None:
+            return True
+        return False
+    
+
+if __name__ == '__main__':
+    time.sleep(2)
+    begin = time.time()
+    pcacc_img.find_maxColor_position((200, 200, 800, 200), {'2EA043'})
+    cost = time.time() - begin
+    print("函数执行耗时:", cost, "秒")

+ 143 - 0
scriptBase/mouseClick.py

@@ -0,0 +1,143 @@
+# -*- coding: utf-8 -*-
+import pyautogui
+import random
+import math
+import time
+import win32api
+import win32con
+
+# 计算贝塞尔曲线上的点
+def bezier(t, points):
+    n = len(points) - 1
+    x = 0
+    y = 0
+    for i in range(n + 1):
+        coefficient = math.comb(n, i) * (1 - t) ** (n - i) * t ** i
+        x += points[i][0] * coefficient
+        y += points[i][1] * coefficient
+    return x, y
+
+def get_durationAndSteps(distance):
+    local_duration = 0
+    local_steps = 0
+    if distance < 500:
+        local_duration = 150 + distance + random.randint(-100, 100)
+        local_steps = 30  + local_duration / 10
+    else:
+        local_duration = 300 + distance / 2 + random.randint(-200, 200)
+        local_steps = 60  + local_duration / 15
+    
+    return local_duration / 1000, int(local_steps)
+
+#生成控制点,需在随机点添加正态分布
+def generate_control_points(start_point, end_point, num_points):
+    control_points = []
+    control_points.append(start_point)
+    
+    # 计算起点和终点之间的距离
+    distance = ((end_point[0] - start_point[0]) ** 2 + (end_point[1] - start_point[1]) ** 2) ** 0.5
+    
+    # 计算每个等分点的距离
+    interval = distance / (num_points + 1)
+
+    srcPoint = start_point
+    
+    for i in range(1, num_points + 1):
+        # 计算当前等分点的位置
+        t = i / (num_points + 1)
+
+        dstPoint = ((end_point[0] - start_point[0]) / num_points * i + start_point[0], (end_point[1] - start_point[1]) / num_points * i + start_point[1])
+        
+        # 生成随机的控制点
+        control_point = (
+            random.uniform(srcPoint[0], dstPoint[0]),
+            random.uniform(srcPoint[1], dstPoint[1])
+        )
+
+        srcPoint = dstPoint
+        
+        # 将控制点添加到列表中
+        control_points.append(control_point)
+
+    out_points = (((end_point[0] - start_point[0]) / num_points / 3 + end_point[0], (end_point[1] - start_point[1]) / num_points / 3 + end_point[1]))
+    
+    control_points.append(out_points)
+    control_points.append(end_point)
+    
+    return control_points
+
+class pcacc_mouse:
+    def __init__(specifically):
+        random.seed()
+
+    @staticmethod
+    def move_mouse(dst_x, dst_y, isQuick = False):
+        random_range = 4
+        # 获取当前鼠标位置作为起点
+        start_x, start_y = pyautogui.position()
+        if abs(dst_x - start_x) < 10 and abs(dst_y - start_y) < 10: #认为已经移到对应位置了
+            return
+        distance = math.sqrt((dst_x - start_x) ** 2 + (dst_y - start_y) ** 2)
+        duration, steps = get_durationAndSteps(distance)
+        points = generate_control_points((start_x, start_y), (dst_x, dst_y), 3)
+        interval = duration / steps
+        for i in range(steps + 1):
+            t = i / steps
+            x, y = bezier(t, points)
+            
+            # 添加随机性到坐标
+            x += random.randint(-random_range, random_range)
+            y += random.randint(-random_range, random_range)
+            
+            # 计算速度和加速度
+            speed_factor = math.sin(t * math.pi)
+            acceleration_factor = 2 * t * (1 - t)
+            speed = speed_factor * (1 + acceleration_factor) * interval
+            if isQuick:
+                speed = speed / 2
+            try:
+                win32api.SetCursorPos((int(x), int(y)))
+            finally:
+                time.sleep(speed)  # 添加停顿时间
+
+    @staticmethod
+    def click(dst_x, dst_y):
+        pcacc_mouse.move_mouse(dst_x, dst_y)
+        win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, dst_x, dst_y, 0, 0)
+        cur_times = random.randint(0, 1)
+        if cur_times == 0:
+            time.sleep(1.0 / random.randint(60, 130))
+        elif cur_times == 1:
+            time.sleep(1.0 / random.randint(100, 200))
+            dst_x = dst_x + random.randint(-3, 3)
+            dst_y = dst_y + random.randint(-3, 3)
+            win32api.SetCursorPos((dst_x, dst_y))
+            time.sleep(1.0 / random.randint(100, 200))
+        win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, dst_x + random.randint(-3, 3), dst_y + random.randint(-3, 3), 0, 0)
+
+    @staticmethod
+    def quickclick(dst_x, dst_y):
+        pcacc_mouse.move_mouse(dst_x, dst_y, True)
+        win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, dst_x, dst_y, 0, 0)
+        time.sleep(1.0 / random.randint(300, 500))
+        win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, dst_x + random.randint(-3, 3), dst_y + random.randint(-3, 3), 0, 0)
+    
+    @staticmethod
+    def drag_from(src_x, src_y, dst_x, dst_y):
+        pcacc_mouse.move_mouse(src_x, src_y)
+        win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, src_x, src_y, 0, 0)
+        pcacc_mouse.move_mouse(dst_x, dst_y)
+        time.sleep(1.0 / random.randint(60, 130))
+        win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, dst_x, dst_y, 0, 0)
+
+    @staticmethod
+    def drag(dst_x, dst_y):
+        src_x, src_y = pyautogui.position()
+        win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, src_x, src_y, 0, 0)
+        pcacc_mouse.move_mouse(dst_x, dst_y)
+        time.sleep(1.0 / random.randint(60, 130))
+        win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, dst_x, dst_y, 0, 0)
+
+if __name__ == '__main__':
+    # 移动鼠标
+    pcacc_mouse.drag_from(500, 500, 100, 100)

+ 16 - 0
scriptBase/ocr.py

@@ -0,0 +1,16 @@
+import pytesseract
+from PIL import Image, ImageGrab
+import tkinter as tk
+import threading
+print(pytesseract.pytesseract.tesseract_cmd)
+
+
+# 定义截图和OCR识别函数
+def capture_and_ocr(region):
+    # 读取屏幕截图
+    screenshot = ImageGrab.grab(bbox=region)
+    
+    # 使用Tesseract进行文字识别
+    result = pytesseract.image_to_string(screenshot, lang='chi_sim')
+    return result
+    

BIN
scriptBase/other/other_calc.png


BIN
scriptBase/other/other_edge.png


BIN
scriptBase/other/other_notepad.png


+ 14 - 0
scriptBase/requirements.txt

@@ -0,0 +1,14 @@
+# -*- coding: utf-8 -*-
+# pip install -r requirements.txt -i https://pypi.douban.com/simple
+
+PyAutoGUI
+pywin32
+opencv-python
+apscheduler
+pygetwindow
+scikit-learn
+matplotlib
+pillow
+requests
+pygetwindow
+gtts

+ 76 - 0
scriptBase/select_orc.py

@@ -0,0 +1,76 @@
+import tkinter as tk
+from PIL import ImageGrab, ImageTk
+import wanguo_config
+
+class RegionSelection:
+    def __init__(self, root, screenshot):
+        self.root = root
+        self.start_x = None
+        self.start_y = None
+        self.end_x = None
+        self.end_y = None
+        self.rectangle = None
+        
+        # 创建截图显示窗口
+        self.screenshot_window = tk.Toplevel(self.root)
+        self.screenshot_window.attributes('-fullscreen', True)
+        self.screenshot_window.attributes('-alpha', 0.3)
+        self.screenshot_canvas = tk.Canvas(self.screenshot_window, bg="white")
+        self.screenshot_canvas.pack(fill=tk.BOTH, expand=True)
+        self.screenshot_photo = ImageTk.PhotoImage(screenshot)
+        self.screenshot_canvas.create_image(0, 0, image=self.screenshot_photo, anchor=tk.NW)
+        
+        # 绑定鼠标事件
+        self.screenshot_canvas.bind("<ButtonPress-1>", self.on_button_press)
+        self.screenshot_canvas.bind("<B1-Motion>", self.on_button_motion)
+        self.screenshot_canvas.bind("<ButtonRelease-1>", self.on_button_release)
+        
+    def on_button_press(self, event):
+        self.start_x = event.x
+        self.start_y = event.y
+        
+    def on_button_motion(self, event):
+        if self.rectangle is not None:
+            self.screenshot_canvas.delete(self.rectangle)
+        
+        self.end_x = event.x
+        self.end_y = event.y
+        
+        self.rectangle = self.screenshot_canvas.create_rectangle(self.start_x, self.start_y, self.end_x, self.end_y, outline="red")
+        
+    def on_button_release(self, event):
+        if self.rectangle is not None:
+            self.screenshot_canvas.delete(self.rectangle)
+        
+        # 返回区域坐标(相对于全屏)
+        x1 = min(self.start_x, self.end_x)
+        y1 = min(self.start_y, self.end_y)
+        x2 = max(self.start_x, self.end_x)
+        y2 = max(self.start_y, self.end_y)
+        
+        # 转换为相对于屏幕左上角的坐标
+        x1 += self.screenshot_window.winfo_rootx()
+        y1 += self.screenshot_window.winfo_rooty()
+        x2 += self.screenshot_window.winfo_rootx()
+        y2 += self.screenshot_window.winfo_rooty()
+        
+        # 返回具体坐标
+        print("选择的区域坐标:", (x1, y1, x2, y2))
+        wanguo_config.g_region = (x1, y1, x2, y2)
+        
+        # 关闭截图显示窗口
+        self.screenshot_window.destroy()
+        
+if __name__ == "__main__":
+    # 初始化Tkinter窗口
+    root = tk.Tk()
+    
+    
+    # 获取全屏截图
+    screenshot = ImageGrab.grab()
+    
+    # 创建区域选择对象
+    region_selection = RegionSelection(root, screenshot)
+    
+    # 运行Tkinter窗口主
+    root.mainloop()