Selaa lähdekoodia

!1 add dongri game auto script

pcacc 5 kuukautta sitten
vanhempi
sitoutus
d59c1922c2
100 muutettua tiedostoa jossa 1091 lisäystä ja 8 poistoa
  1. BIN
      __pycache__/dongri_define.cpython-311.pyc
  2. BIN
      __pycache__/dongri_pic.cpython-311.pyc
  3. BIN
      __pycache__/dongri_task.cpython-311.pyc
  4. 233 0
      app_dongri.py
  5. 2 0
      compact_log.txt
  6. 11 0
      dongri_define.py
  7. BIN
      dongri_img/check/adventure.png
  8. BIN
      dongri_img/check/auto_confilit.png
  9. BIN
      dongri_img/check/bigGet.png
  10. BIN
      dongri_img/check/build_upgrade.png
  11. BIN
      dongri_img/check/conflits.png
  12. BIN
      dongri_img/check/detail.png
  13. BIN
      dongri_img/check/donate.png
  14. BIN
      dongri_img/check/donate2.png
  15. BIN
      dongri_img/check/get.png
  16. BIN
      dongri_img/check/hand.png
  17. BIN
      dongri_img/check/help.png
  18. BIN
      dongri_img/check/help2.png
  19. BIN
      dongri_img/check/help3.png
  20. BIN
      dongri_img/check/institude.png
  21. BIN
      dongri_img/check/needgo.png
  22. BIN
      dongri_img/check/paticipate.png
  23. BIN
      dongri_img/check/research.png
  24. BIN
      dongri_img/check/research_done.png
  25. BIN
      dongri_img/check/research_type1.png
  26. BIN
      dongri_img/check/research_type2.png
  27. BIN
      dongri_img/check/storeroom.png
  28. BIN
      dongri_img/check/technology_better.png
  29. BIN
      dongri_img/check/union.png
  30. BIN
      dongri_img/check/union_technology.png
  31. BIN
      dongri_img/check/upgrade_done.png
  32. BIN
      dongri_img/check/upgrade_done2.png
  33. BIN
      dongri_img/check/upgrade_done3.png
  34. BIN
      dongri_img/check/upgrade_next.png
  35. BIN
      dongri_img/gameStart/close.png
  36. BIN
      dongri_img/gameStart/ico.png
  37. BIN
      dongri_img/information/add_strength.png
  38. BIN
      dongri_img/information/camp1.png
  39. BIN
      dongri_img/information/camp2.png
  40. BIN
      dongri_img/information/explore.png
  41. BIN
      dongri_img/information/fight.png
  42. BIN
      dongri_img/information/gotosee.png
  43. BIN
      dongri_img/information/hero0.png
  44. BIN
      dongri_img/information/hero1.png
  45. BIN
      dongri_img/information/hero2.png
  46. BIN
      dongri_img/information/hero_fight.png
  47. BIN
      dongri_img/information/information.png
  48. BIN
      dongri_img/information/survive.png
  49. BIN
      dongri_img/information/wolf0.png
  50. BIN
      dongri_img/information/wolf1.png
  51. BIN
      dongri_img/information/wolf2.png
  52. BIN
      dongri_img/monster/all_select.png
  53. BIN
      dongri_img/monster/attack.png
  54. BIN
      dongri_img/monster/begin_multi.png
  55. BIN
      dongri_img/monster/bigMonster.png
  56. BIN
      dongri_img/monster/collect.png
  57. BIN
      dongri_img/monster/enough_strengh.png
  58. BIN
      dongri_img/monster/enter.png
  59. BIN
      dongri_img/monster/fight.png
  60. BIN
      dongri_img/monster/fight2.png
  61. BIN
      dongri_img/monster/iron.png
  62. BIN
      dongri_img/monster/line1.png
  63. BIN
      dongri_img/monster/line2.png
  64. BIN
      dongri_img/monster/line3.png
  65. BIN
      dongri_img/monster/line4.png
  66. BIN
      dongri_img/monster/meat.png
  67. BIN
      dongri_img/monster/mine.png
  68. BIN
      dongri_img/monster/muti_team.png
  69. BIN
      dongri_img/monster/no_hero.png
  70. BIN
      dongri_img/monster/participate.png
  71. BIN
      dongri_img/monster/returnLine.png
  72. BIN
      dongri_img/monster/search.png
  73. BIN
      dongri_img/monster/tasklist.png
  74. BIN
      dongri_img/monster/wolf.png
  75. BIN
      dongri_img/monster/wood.png
  76. BIN
      dongri_img/place/back1.png
  77. BIN
      dongri_img/place/back2.png
  78. BIN
      dongri_img/place/back3.png
  79. BIN
      dongri_img/place/gameIn.png
  80. BIN
      dongri_img/place/help.png
  81. BIN
      dongri_img/place/ico.png
  82. BIN
      dongri_img/place/ico2.png
  83. BIN
      dongri_img/place/outside.png
  84. BIN
      dongri_img/place/title.png
  85. BIN
      dongri_img/place/town.png
  86. BIN
      dongri_img/train/begin_train.png
  87. BIN
      dongri_img/train/dun.png
  88. BIN
      dongri_img/train/enter.png
  89. BIN
      dongri_img/train/getAll.png
  90. BIN
      dongri_img/train/gong.png
  91. BIN
      dongri_img/train/mao.png
  92. BIN
      dongri_img/train/quick_panel.png
  93. BIN
      dongri_img/train/train.png
  94. BIN
      dongri_img/train/train_success.png
  95. 114 0
      dongri_pic.py
  96. 559 0
      dongri_task.py
  97. 13 6
      scriptBase/comon.py
  98. 2 2
      scriptBase/imgFind.py
  99. 7 0
      scriptBase/mouseClick.py
  100. 150 0
      templates/index_dongri.html

BIN
__pycache__/dongri_define.cpython-311.pyc


BIN
__pycache__/dongri_pic.cpython-311.pyc


BIN
__pycache__/dongri_task.cpython-311.pyc


+ 233 - 0
app_dongri.py

@@ -0,0 +1,233 @@
+# -*- coding: utf-8 -*-
+import datetime
+from flask import Flask, render_template
+from flask_socketio import SocketIO, emit
+from scriptBase.comon import *
+import pyautogui
+import base64
+import threading
+from dongri_task import *
+from collections import deque
+import json
+
+app = Flask(__name__)
+socketio = SocketIO(app)
+event = threading.Event()
+g_status = ''
+last_time = 0.0
+task_queue = deque()
+last_process = ''
+isGameBegin = True
+autoTask = None
+isReset = False
+
+def thread_runTask():
+    global last_process
+    global task_queue,isReset
+    while True:
+        if event.is_set():
+            task_queue.clear()
+        if len(task_queue) != 0:
+            task = task_queue[-1]
+            task_queue.pop()
+            last_process = task.name
+            task.run()
+            myTimeSleep_small()
+        else:
+            myTimeSleep_big()
+        if isReset:
+            isReset = False
+            restart_game()
+
+
+@app.route('/')
+def index():
+    return render_template('index_dongri.html')
+
+@socketio.on('connect')
+def handle_connect():
+    print('Client connected')
+
+@socketio.on('disconnect')
+def handle_disconnect():
+    print('Client disconnected')
+
+def send_hint(msg):#数组信息
+    emit('processing_hint', msg)
+
+def send_status(msg):#软件执行状态
+    global g_status
+    try:
+        if msg == '':
+            emit('processing_status', g_status)
+            return
+        else:
+            g_status = msg
+        
+        if msg == "结束":
+            event.clear()
+        emit('processing_status', msg)
+    except:
+        return
+
+
+@socketio.on('monitor_begin')
+def monitor_begin():
+    global last_time, last_process
+    current_time = time.time()
+    elapsed_time = current_time - last_time
+    if elapsed_time < 0.5:
+        return
+    last_time = current_time
+    regionRet, regionPos = game_region()
+    screenshot = pyautogui.screenshot(region=regionPos)
+    binary_img = binarize_image(screenshot)
+    compressed_data = compress_image(binary_img)
+    
+    image_data_base64 = base64.b64encode(compressed_data).decode('utf-8')
+    socketio.emit('image_data', image_data_base64)
+    task_arr = []
+    if not event.is_set():
+        task_arr.append(last_process)
+    for item in reversed(task_queue):
+        task_arr.append(item.name)
+    send_hint(json.dumps(task_arr, ensure_ascii=False))
+    send_status('')
+    #print("send img")
+
+@socketio.on('end_script')
+def handle_end_script():
+    event.set()
+
+@socketio.on('end_game')
+def handle_end_game():
+    event.set()
+    task_close_game()
+    send_status("结束2")
+    event.clear()
+
+@socketio.on('get_title')
+def handle_get_title():
+    str = task_getComputerName()
+    dst = str + ' machine'
+    emit('processing_title', dst)
+
+@socketio.on('reset_script')
+def handle_reset_script():
+    python = sys.executable
+    while '--reset' in sys.argv:
+    # 从 sys.argv 列表中删除 --reset 参数
+        sys.argv.remove('--reset')
+    os.execl(python, python, *sys.argv)
+
+@socketio.on('restart_game')
+def handle_restart_game():
+    python = sys.executable
+    os.execl(python, python, *sys.argv, '--reset')
+
+def restart_game():
+    global isGameBegin, autoTask
+    isGameBegin = False
+    while True:
+        task_close_game()
+        if True == task_start_game():
+            break
+        else:
+            send_status("启动失败")
+    isGameBegin = True
+    send_status("结束")
+    auto_task(None)
+
+def auto_participate():
+    task_queue.appendleft(task_returnAllLine())
+
+    timeout = 40 * 60
+    start_time = time.time()  # 记录开始时间
+
+
+    while not event.is_set():
+        if len(task_queue) < 4:
+            task_queue.appendleft(task_paticipateInTeam())
+            task_queue.appendleft(task_checkHelp(True))
+        myTimeSleep_big()
+        # 每次循环检查已用时间
+        current_time = time.time()
+        elapsed_time = current_time - start_time
+        
+        if elapsed_time >= timeout:
+            handle_restart_game()
+            break
+
+
+
+
+def add_auto_task(isMaxCollect):
+    collectType = 0
+    if isMaxCollect:
+        collectType = 5
+    times = 0
+    while not event.is_set():
+        task_queue.appendleft(task_information())
+        task_queue.appendleft(task_checkHelp(False))
+        task_queue.appendleft(check_buildOrResearch())
+        task_queue.appendleft(task_fightMonster(False, True))
+        task_queue.appendleft(task_collect(collectType))
+        task_queue.appendleft(task_train())
+        task_queue.appendleft(task_collect(collectType))
+        task_queue.appendleft(task_train())
+        task_queue.appendleft(task_collect(collectType))
+        task_queue.appendleft(task_checkStoreRoom())
+        task_queue.appendleft(task_checkConfilits())
+        task_queue.appendleft(task_checkDonata())
+        #task_queue.appendleft(task_waitTime())
+        times += 1
+        if times == 5:
+            task_queue.appendleft(task_checkAdventure())
+        if times == 10:
+            handle_end_game()
+            myTimeSleep(random.randint(1000, 2000), send_status)
+            handle_restart_game()
+        else:
+            myTimeSleep(random.randint(600, 1000), send_status)
+            
+        
+    task_queue.clear()
+    send_status(f'自动模式结束')
+    event.clear()
+        
+        
+
+@socketio.on('begin_auto')
+def handle_auto(data):
+    auto_task(data)
+
+def auto_task(data):
+    global autoTask
+    if data == None:
+        isMaxCollect = False
+    else:
+        isMaxCollect = data['maxCollect']
+    send_status(f'开始自动模式')
+    autoTask = threading.Thread(target=add_auto_task, args=(isMaxCollect,))#启动线程往里面添加任务
+    autoTask.daemon = True
+    autoTask.start()
+
+@socketio.on('begin_auto_participate')
+def handle_auto_participate():
+    global autoTask
+    send_status(f'开始自动集结模式')
+    autoTask = threading.Thread(target=auto_participate)#启动线程往里面添加任务
+    autoTask.daemon = True
+    autoTask.start()
+
+
+if __name__ == '__main__':
+    init()
+    if '--reset' in sys.argv:
+        isReset = True
+        print("需要重启游戏")
+    runTask = threading.Thread(target=thread_runTask)#启动线程往里面添加任务
+    runTask.daemon = True
+    runTask.start()
+    
+    socketio.run(app, host= '0.0.0.0', debug=True)

+ 2 - 0
compact_log.txt

@@ -0,0 +1,2 @@
+2025-02-14T04:45:27.028015300Z : ready compact 'C:\Program Files\Netease\MuMuPlayer-12.0\vms\MuMuPlayer-12.0-0\data.vdi'
+this time is dry-run, total blocks: 48806, used blocks: 5397, fragment ratio: 0.0472485

+ 11 - 0
dongri_define.py

@@ -0,0 +1,11 @@
+from enum import Enum
+
+class PLACE(Enum):
+    NONE = 0 #未知
+    SEARCH = 1 #探索界面
+    TOWN = 2 #庭院
+    OUTSIDE = 3 #町中
+
+class YAOQI(Enum):
+    GUISHIHEI = 1 #鬼使黑
+    RIHEFANG = 2 #日和坊

BIN
dongri_img/check/adventure.png


BIN
dongri_img/check/auto_confilit.png


BIN
dongri_img/check/bigGet.png


BIN
dongri_img/check/build_upgrade.png


BIN
dongri_img/check/conflits.png


BIN
dongri_img/check/detail.png


BIN
dongri_img/check/donate.png


BIN
dongri_img/check/donate2.png


BIN
dongri_img/check/get.png


BIN
dongri_img/check/hand.png


BIN
dongri_img/check/help.png


BIN
dongri_img/check/help2.png


BIN
dongri_img/check/help3.png


BIN
dongri_img/check/institude.png


BIN
dongri_img/check/needgo.png


BIN
dongri_img/check/paticipate.png


BIN
dongri_img/check/research.png


BIN
dongri_img/check/research_done.png


BIN
dongri_img/check/research_type1.png


BIN
dongri_img/check/research_type2.png


BIN
dongri_img/check/storeroom.png


BIN
dongri_img/check/technology_better.png


BIN
dongri_img/check/union.png


BIN
dongri_img/check/union_technology.png


BIN
dongri_img/check/upgrade_done.png


BIN
dongri_img/check/upgrade_done2.png


BIN
dongri_img/check/upgrade_done3.png


BIN
dongri_img/check/upgrade_next.png


BIN
dongri_img/gameStart/close.png


BIN
dongri_img/gameStart/ico.png


BIN
dongri_img/information/add_strength.png


BIN
dongri_img/information/camp1.png


BIN
dongri_img/information/camp2.png


BIN
dongri_img/information/explore.png


BIN
dongri_img/information/fight.png


BIN
dongri_img/information/gotosee.png


BIN
dongri_img/information/hero0.png


BIN
dongri_img/information/hero1.png


BIN
dongri_img/information/hero2.png


BIN
dongri_img/information/hero_fight.png


BIN
dongri_img/information/information.png


BIN
dongri_img/information/survive.png


BIN
dongri_img/information/wolf0.png


BIN
dongri_img/information/wolf1.png


BIN
dongri_img/information/wolf2.png


BIN
dongri_img/monster/all_select.png


BIN
dongri_img/monster/attack.png


BIN
dongri_img/monster/begin_multi.png


BIN
dongri_img/monster/bigMonster.png


BIN
dongri_img/monster/collect.png


BIN
dongri_img/monster/enough_strengh.png


BIN
dongri_img/monster/enter.png


BIN
dongri_img/monster/fight.png


BIN
dongri_img/monster/fight2.png


BIN
dongri_img/monster/iron.png


BIN
dongri_img/monster/line1.png


BIN
dongri_img/monster/line2.png


BIN
dongri_img/monster/line3.png


BIN
dongri_img/monster/line4.png


BIN
dongri_img/monster/meat.png


BIN
dongri_img/monster/mine.png


BIN
dongri_img/monster/muti_team.png


BIN
dongri_img/monster/no_hero.png


BIN
dongri_img/monster/participate.png


BIN
dongri_img/monster/returnLine.png


BIN
dongri_img/monster/search.png


BIN
dongri_img/monster/tasklist.png


BIN
dongri_img/monster/wolf.png


BIN
dongri_img/monster/wood.png


BIN
dongri_img/place/back1.png


BIN
dongri_img/place/back2.png


BIN
dongri_img/place/back3.png


BIN
dongri_img/place/gameIn.png


BIN
dongri_img/place/help.png


BIN
dongri_img/place/ico.png


BIN
dongri_img/place/ico2.png


BIN
dongri_img/place/outside.png


BIN
dongri_img/place/title.png


BIN
dongri_img/place/town.png


BIN
dongri_img/train/begin_train.png


BIN
dongri_img/train/dun.png


BIN
dongri_img/train/enter.png


BIN
dongri_img/train/getAll.png


BIN
dongri_img/train/gong.png


BIN
dongri_img/train/mao.png


BIN
dongri_img/train/quick_panel.png


BIN
dongri_img/train/train.png


BIN
dongri_img/train/train_success.png


+ 114 - 0
dongri_pic.py

@@ -0,0 +1,114 @@
+
+class gameStart_img:
+    # = R'dongri_img\gameStart\.png'
+    ico = R'dongri_img\gameStart\ico.png'
+    close = R'dongri_img\gameStart\close.png'
+
+class place_img:
+    # = R'dongri_img\place\.png'
+    title = R'dongri_img\place\title.png'
+    ico = R'dongri_img\place\ico.png'
+    ico2 = R'dongri_img\place\ico2.png'
+    back1 = R'dongri_img\place\back1.png'
+    back2 = R'dongri_img\place\back2.png'
+    back3 = R'dongri_img\place\back3.png'
+    gameIn = R'dongri_img\place\gameIn.png'
+    town = R'dongri_img\place\town.png'
+    outside = R'dongri_img\place\outside.png'
+    help = R'dongri_img\place\help.png'
+
+class monster_img:
+    # = R'dongri_img\monster\.png'
+    tasklist = R'dongri_img\monster\tasklist.png'
+    meat = R'dongri_img\monster\meat.png'
+    wood = R'dongri_img\monster\wood.png'
+    mine = R'dongri_img\monster\mine.png'
+    iron = R'dongri_img\monster\iron.png'
+    search = R'dongri_img\monster\search.png'
+    collect = R'dongri_img\monster\collect.png'
+    fight = R'dongri_img\monster\fight.png'
+    fight2 = R'dongri_img\monster\fight2.png'
+    wolf = R'dongri_img\monster\wolf.png'
+    bigMonster = R'dongri_img\monster\bigMonster.png'
+    muti_team = R'dongri_img\monster\muti_team.png'
+    begin_multi = R'dongri_img\monster\begin_multi.png'
+    no_hero = R'dongri_img\monster\no_hero.png'
+    line1 = R'dongri_img\monster\line1.png'
+    line2 = R'dongri_img\monster\line2.png'
+    line3 = R'dongri_img\monster\line3.png'
+    line4 = R'dongri_img\monster\line4.png'
+    all_select = R'dongri_img\monster\all_select.png'
+    attack = R'dongri_img\monster\attack.png'
+    enough_strengh = R'dongri_img\monster\enough_strengh.png'
+    returnLine = R'dongri_img\monster\returnLine.png'
+    enter = R'dongri_img\monster\enter.png'
+    participate = R'dongri_img\monster\participate.png'
+    move_right = (418, 604, 135, 616)
+    move_left = (135, 616, 418, 604)
+
+class train_img:
+    # = R'dongri_img\game\.png' 
+    quick_panel = R'dongri_img\train\quick_panel.png'
+    train_success = R'dongri_img\train\train_success.png'
+    dun = R'dongri_img\train\dun.png'
+    mao = R'dongri_img\train\mao.png'
+    gong = R'dongri_img\train\gong.png'
+    train = R'dongri_img\train\train.png'
+    begin_train = R'dongri_img\train\begin_train.png'
+    getAll = R'dongri_img\train\getAll.png'
+    enter = R'dongri_img\train\enter.png'
+
+class check_img:
+    # = R'dongri_img\check\.png'
+    move_down = (222,508,240,314)
+    storeroom = R'dongri_img\check\storeroom.png'
+    needgo = R'dongri_img\check\needgo.png'
+    institude = R'dongri_img\check\institude.png'
+    build_upgrade = R'dongri_img\check\build_upgrade.png'
+    research = R'dongri_img\check\research.png'
+    hand = R'dongri_img\check\hand.png'
+    detail = R'dongri_img\check\detail.png'
+    upgrade_done = R'dongri_img\check\upgrade_done.png'
+    upgrade_done2 = R'dongri_img\check\upgrade_done2.png'
+    upgrade_done3 = R'dongri_img\check\upgrade_done3.png'
+    upgrade_next = R'dongri_img\check\upgrade_next.png'
+    research_type1 = R'dongri_img\check\research_type1.png'
+    research_type2 = R'dongri_img\check\research_type2.png'
+    research_done = R'dongri_img\check\research_done.png'
+    help = R'dongri_img\check\help.png'
+    help2 = R'dongri_img\check\help2.png'
+    help3 = R'dongri_img\check\help3.png'
+    conflits = R'dongri_img\check\conflits.png'
+    paticipate = R'dongri_img\check\paticipate.png'
+    auto_confilit = R'dongri_img\check\auto_confilit.png'
+    union = R'dongri_img\check\union.png'
+    union_technology = R'dongri_img\check\union_technology.png'
+    technology_better = R'dongri_img\check\technology_better.png'
+    donate = R'dongri_img\check\donate.png'
+    donate2 = R'dongri_img\check\donate2.png'
+    adventure = R'dongri_img\check\adventure.png'
+    get = R'dongri_img\check\get.png'
+    bigGet = R'dongri_img\check\bigGet.png'
+
+class information_img:
+    # = R'dongri_img\information\.png'
+    information = R'dongri_img\information\information.png'
+    camp1 = R'dongri_img\information\camp1.png'
+    camp2 = R'dongri_img\information\camp2.png'
+    wolf0 = R'dongri_img\information\wolf0.png'
+    wolf1 = R'dongri_img\information\wolf1.png'
+    wolf2 = R'dongri_img\information\wolf2.png'
+    hero0 = R'dongri_img\information\hero0.png'
+    hero1 = R'dongri_img\information\hero1.png'
+    hero2 = R'dongri_img\information\hero2.png'
+    fight = R'dongri_img\information\fight.png'
+    gotosee = R'dongri_img\information\gotosee.png'
+    survive = R'dongri_img\information\survive.png'
+    explore = R'dongri_img\information\explore.png'
+    hero_fight = R'dongri_img\information\hero_fight.png'
+    add_strength = R'dongri_img\information\add_strength.png'
+
+
+
+
+_imported = False

+ 559 - 0
dongri_task.py

@@ -0,0 +1,559 @@
+# -*- coding: utf-8 -*-
+from scriptBase.imgFind import pcacc_img, savePic
+from scriptBase.mouseClick import pcacc_mouse
+from scriptBase.ocr import capture_and_ocr
+
+import scriptBase.base
+from scriptBase.comon import *
+from scriptBase.ocr import *
+from apscheduler.schedulers.blocking import BlockingScheduler
+import pyautogui
+import random
+import sys
+import math
+import os
+import time
+from dongri_define import *
+from dongri_pic import *
+import subprocess
+import socket
+from dongri_pic import _imported
+
+
+
+
+'''
+基础配置说明:
+600*800(DPI 300)
+游戏画面:流畅
+高帧率关闭
+町中模式:旧版
+
+'''
+
+def task_getComputerName():
+    return socket.gethostname()
+
+def task_acceptTask():
+    while True:
+        myTimeSleep_big()
+
+
+def init():
+    global _imported
+    if not _imported:
+        acceptTask = threading.Thread(target=task_acceptTask)
+        acceptTask.daemon = True
+        if acceptTask.is_alive() == False:
+            acceptTask.start()
+            _imported = True
+
+class basic_operate:
+    @staticmethod
+    def do_back():
+        task_return_game()
+        ret = False
+        ret |= waitClickImg_noWait_withBool(place_img.back1, 0.6, 0)
+        if ret:
+            return
+        ret |= waitClickImg_noWait_withBool(place_img.back2, 0.6, 0)
+        if ret:
+            return
+        ret |= waitClickImg_noWait_withBool(place_img.back3, 0.6, 0)
+        if ret:
+            return
+        ret, pos = waitFindImg(place_img.title, 1, 0)
+        if ret:
+            pcacc_mouse.click(pos[0], pos[1] + 40)
+
+
+    def backToGame(preTime = 0):
+        tryMaxTimes = 5
+        while tryMaxTimes > 0:
+            tryMaxTimes -= 1
+            if waitFindImg_withBool(place_img.gameIn, 1, preTime) == False:
+                basic_operate.do_back()
+            else:
+                return True
+        return False
+    
+    @staticmethod
+    def go_town(preTime = 0):
+        if basic_operate.backToGame(preTime) == False:
+            return False
+
+        waitClickImg_noWait_withBool(place_img.outside, 0.6, 0)
+        return True
+    
+    @staticmethod
+    def go_outside(preTime = 0):
+        if basic_operate.backToGame(preTime) == False:
+            return False
+
+        waitClickImg_noWait_withBool(place_img.town, 0.6, 0)
+        return True
+    
+    @staticmethod
+    def click_outside_search():
+        taskListRet, taskListPos =  waitFindImg(monster_img.tasklist, 2, 3)
+        if taskListRet == False:
+            return False
+        else:
+            pcacc_mouse.click(taskListPos[0], taskListPos[1] - 110)#click search
+
+        myTimeSleep_big()
+        return True
+    
+    @staticmethod
+    def enter_auto_supply_resource(enter_pic):
+        if waitClickImg_noWait_withBool(enter_pic, 2, 2) == False:
+            return False
+        
+        if waitClickImg_noWait_withBool(train_img.getAll, 2, 1) == False:
+            return True
+        
+        if waitClickImg_noWait_withBool(train_img.enter, 2, 1) == False:
+            return False
+        
+        if waitClickImg_noWait_withBool(enter_pic, 2, 1) == False:
+            return False
+        return True
+    
+    @staticmethod
+    def return_line():
+        if waitClickImg_noWait_withBool(monster_img.returnLine, 2, 1) == False:
+            return False
+        if waitClickImg_noWait_withBool(monster_img.enter, 2, 1) == False:
+            return False
+        return True
+        
+        
+
+
+
+def task_return_game():
+    tryTimes = 3
+    while tryTimes > 0:
+        if False == waitFindImg_withBool([place_img.title], 1, 1):
+            waitClickImg_noWait([place_img.ico, place_img.ico2], 1, 0)
+            myTimeSleep_big()
+            tryTimes -= 1
+            if tryTimes == 0:
+                return False
+        else:
+            break
+
+
+def task_save_compress_pic():
+    # 截取屏幕截图
+    screenshot = pyautogui.screenshot()
+    compressed_data = compress_image(screenshot)
+
+    # 保存压缩后的图像到文件
+    with open('compressed_screenshot.jpg', 'wb') as f:
+        f.write(compressed_data)
+
+def task_close_game():
+    subprocess.call(f"taskkill /f /im MuMuPlayer.exe")
+    subprocess.call(f"taskkill /f /im MuMuVMMHeadless.exe")
+    subprocess.call(f"taskkill /f /im MuMuVMMSVC.exe")
+    myTimeSleep_big()
+
+def task_start_game():
+    isSuccess = True
+    path1 = R'C:\\Program Files\\Netease\\MuMuPlayer-12.0\\shell\\MuMuPlayer.exe'
+    path2 = R'C:\Program Files\Netease\MuMu Player 12\shell\MuMuPlayer.exe'
+    if os.path.exists(path1):
+        subprocess.Popen(path1)
+    elif os.path.exists(path2):
+        subprocess.Popen(path2)
+    if waitClickImg_withBool(gameStart_img.ico, 100, 20) == False:
+        return False
+    
+    waitFindImg_withBool(place_img.gameIn, 10, 20)
+    basic_operate.go_town()
+    waitFindImg_withBool(place_img.gameIn, 10, 20)
+    basic_operate.go_town()
+    if waitFindImg_withBool(place_img.gameIn, 10, 20) == False:
+        return False
+
+    myTimeSleep_big()
+
+    return isSuccess
+
+class dongri_task:
+    def __init__(self, name):
+        self.name = name
+
+    def run(self):
+        print(f"Running task: {self.name}")
+
+
+class task_fightMonster(dongri_task):
+    def __init__(self, add_strengh, fight_bigMonster):
+        super().__init__(f"战斗怪物")
+        self.add_strengh = add_strengh
+        if fight_bigMonster == True:
+            self.monster = monster_img.bigMonster
+            self.attack = monster_img.muti_team
+        else:
+            self.monster = monster_img.wolf
+            self.attack = monster_img.attack
+
+    def run(self):
+        basic_operate.go_outside()
+
+        if False == basic_operate.click_outside_search():
+            return False
+        
+        if False == waitFindImg_withBool(monster_img.enough_strengh, 2, 1):
+            print("没有足够的体力了")
+            return False
+        
+        if waitFindImg_withBool(monster_img.search, 2, 1):
+            myTimeSleep_big()
+            yys_dragAuto(monster_img.move_left)
+        if waitClickImg_noWait_withBool(self.monster, 2, 1) == False:
+            return False
+        if waitClickImg_noWait_withBool(monster_img.search, 2, 1) == False:
+            return False
+        if waitClickImg_noWait_withBool(self.attack, 2, 1) == False:
+            return False
+        waitClickImg_noWait_withBool(monster_img.begin_multi, 2, 1)
+        if waitClickImg_noWait_withBool(monster_img.line1, 2, 1) == False:
+            return False
+        if waitFindImg_withBool(monster_img.no_hero, 2, 1) == True:
+            return False
+        waitClickImg_noWait_withBool(monster_img.all_select, 2, 1)
+        waitClickImg_noWait_withBool(monster_img.all_select, 2, 1)
+
+        maxTryTimes = 3
+        while maxTryTimes > 0:
+            maxTryTimes -= 1
+            waitClickImg_withBool([monster_img.fight, monster_img.fight2], 2, 1)
+            waitClickImg_noWait_withBool(monster_img.all_select, 2, 1)
+
+        return True
+        
+
+class task_collect(dongri_task):
+    def __init__(self, type = 0):
+        if type == 0:
+            typeArr = [4,3,2,1]
+            type = typeArr[random.randint(0, len(typeArr) - 1)]
+        elif type == 5:
+            typeArr = [2,1]
+            type = typeArr[random.randint(0, len(typeArr) - 1)]
+
+        if type == 1:
+            self.type = monster_img.meat
+            self.line = monster_img.line2
+            super().__init__(f"采集肉")
+        elif type == 2:
+            self.type = monster_img.wood
+            self.line = monster_img.line3
+            super().__init__(f"采集木头")
+        elif type == 3:
+            self.type = monster_img.mine
+            self.line = None
+            super().__init__(f"采矿石")
+        elif type == 4:
+            self.type = monster_img.iron
+            self.line = None
+            super().__init__(f"采集铁矿石")
+        
+
+    def run(self):
+        basic_operate.go_outside()
+        if False == basic_operate.click_outside_search():
+            return False
+        
+        if waitFindImg_withBool(monster_img.search, 2, 1):
+            myTimeSleep_big()
+            yys_dragAuto(monster_img.move_right)
+
+        if waitClickImg_noWait_withBool(self.type, 2, 1) == False:
+            return False
+        if waitClickImg_noWait_withBool(monster_img.search, 2, 1) == False:
+            return False
+        if waitClickImg_withBool(monster_img.collect, 2, 1) == False:
+            return False
+        
+        if self.line != None:
+            waitClickImg_noWait_withBool(self.line, 2, 1)
+
+        waitClickImg_noWait_withBool(monster_img.all_select, 2, 1)
+        waitClickImg_noWait_withBool(monster_img.all_select, 2, 1)
+        
+        maxTryTimes = 3
+        while maxTryTimes > 0:
+            maxTryTimes -= 1
+            waitClickImg_withBool([monster_img.fight, monster_img.fight2], 2, 1)
+            waitClickImg_noWait_withBool(monster_img.all_select, 2, 1)
+        return True
+        
+class task_train(dongri_task):
+    def __init__(self):
+        super().__init__(f"检查训练")
+    def run(self):
+        basic_operate.go_town()
+        if waitClickImg_noWait_withBool(train_img.quick_panel, 2, 1) == False:
+            return False
+        if waitClickImg_noWait_withBool(train_img.train_success, 2, 1) == False:
+            return False
+        tryTimes = 3
+        while tryTimes > 0:
+            tryTimes -= 1
+            waitClickImg_noWait_withBool([train_img.dun, train_img.gong, train_img.mao], 2, 1)
+
+            if waitClickImg_noWait_withBool(train_img.train, 2, 1):
+                break
+        return basic_operate.enter_auto_supply_resource(train_img.begin_train)
+
+class task_checkHelp(dongri_task):
+    def __init__(self, isOutSide = False):
+        super().__init__(f"检查帮助")
+        self.isOutSide = isOutSide
+    def run(self):
+        if self.isOutSide:
+            basic_operate.go_outside()
+        else:
+            basic_operate.go_town()
+        waitClickImg_noWait_withBool(place_img.help, 2, 1)
+        return True
+    
+class task_checkStoreRoom(dongri_task):
+    def __init__(self):
+        super().__init__(f"检查仓库")
+    def run(self):
+        basic_operate.go_town()
+        if waitClickImg_noWait_withBool(train_img.quick_panel, 2, 1) == False:
+            return False
+        
+        myTimeSleep_big()
+        yys_dragAuto(check_img.move_down)
+        if waitClickImg_noWait_withBool(train_img.train_success, 2, 1) == False:
+            return False
+        myTimeSleep_big()
+        pcacc_mouse.quickclick_current()
+        if waitClickImg_noWait_withBool(check_img.storeroom, 2, 1) == False:
+            return False
+        return True
+    
+class task_checkConfilits(dongri_task):
+    def __init__(self):
+        super().__init__(f"检查集结")
+    def run(self):
+        basic_operate.go_outside()
+        if waitClickImg_noWait_withBool(check_img.conflits, 2, 1) == False:
+            return False
+        if waitClickImg_noWait_withBool(check_img.paticipate, 2, 1) == False:
+            return False
+        if waitClickImg_noWait_withBool(check_img.auto_confilit, 2, 1) == False:
+            return False
+        return True
+
+class task_checkDonata(dongri_task):
+    def __init__(self):
+        super().__init__(f"检查捐献")
+    def run(self):
+        basic_operate.go_town()
+        if waitClickImg_noWait_withBool(check_img.union, 2, 1) == False:
+            return False
+        if waitClickImg_noWait_withBool(check_img.union_technology, 2, 1) == False:
+            return False
+        if waitClickImg_noWait_withBool(check_img.technology_better, 2, 1) == False:
+            return False
+        if waitClickImg_withBool([check_img.donate, check_img.donate2], 2, 1) == False:
+            return False
+        else:
+            maxTryTimes = 3
+            while waitClickImg_withBool([check_img.donate, check_img.donate2], 1, 0) and maxTryTimes > 0:
+                maxTryTimes -= 1
+        return True
+
+class task_checkAdventure(dongri_task):
+    def __init__(self):
+        super().__init__(f"检查冒险")
+    def run(self):
+        basic_operate.go_town()
+        if waitClickImg_noWait_withBool(check_img.adventure, 2, 1) == False:
+            return False
+        if waitClickImg_noWait_withBool(check_img.get, 2, 1) == False:
+            return False
+        if waitClickImg_noWait_withBool(check_img.bigGet, 2, 1) == False:
+            return False
+        return True
+
+class task_waitTime(dongri_task):
+    def __init__(self):
+        super().__init__(f"等待时间")
+    def run(self):
+        myTimeSleep(300)
+
+class check_buildOrResearch(dongri_task):
+    def __init__(self):
+        super().__init__(f"检查建筑或研究")
+    def run(self):
+        basic_operate.go_town()
+        if waitClickImg_noWait_withBool(train_img.quick_panel, 2, 1) == False:
+            return False
+        
+        if waitClickImg_noWait_withBool(check_img.needgo, 2, 1) == False:
+            return False
+        
+        dstType = 'none'
+        while True:
+            if waitFindImg_withBool([check_img.upgrade_done, check_img.upgrade_done2, check_img.upgrade_done3, check_img.upgrade_next], 2, 1):
+                dstType = 'build'
+                break
+            handRet, handPos = waitFindImg(check_img.hand, 2, 1)
+            if not handRet:
+                return False
+            
+            detailRet, detailPos = waitFindImg(check_img.detail, 2, 1)
+            dstPos = [0, 0]
+            if not detailRet:
+                # 如果找不到详细信息,兵营之类的,需点中间
+                dstPos = [handPos[0] - 70, handPos[1] + 120]
+            else:
+                dstPos = [detailPos[0] + 70, detailPos[1] - 100]
+
+            tryTimes = 5
+            
+            while tryTimes > 0:
+                tryTimes -= 1
+                myTimeSleep_big()
+                pcacc_mouse.click(dst_x=dstPos[0], dst_y=dstPos[1])
+                if waitClickImg_noWait_withBool(check_img.research, 2, 1):
+                    dstType = 'research'
+                    break
+                elif waitClickImg_noWait_withBool(check_img.build_upgrade, 2, 1):
+                    dstType = 'build'
+                    break
+            break
+        if dstType == 'none':
+            print('没有找到建筑或研究')
+            return False
+        elif dstType == 'build':
+            while basic_operate.enter_auto_supply_resource([check_img.upgrade_done, check_img.upgrade_done2, check_img.upgrade_done3, check_img.upgrade_next]):
+                continue
+        elif dstType == 'research':
+            if waitClickImg_withBool([check_img.research_type1, check_img.research_type2], 2, 1) == False:
+                return False
+            if basic_operate.enter_auto_supply_resource(check_img.research_done) == False:
+                return False
+            
+        waitClickImg_withBool([check_img.help, check_img.help2, check_img.help3], 2, 2)
+        return True
+                
+class task_information(dongri_task):
+    def __init__(self):
+        super().__init__(f"检查情报")
+    def run(self):
+        basic_operate.go_outside()
+        if waitClickImg_noWait_withBool(information_img.information, 2, 1) == False:
+            return False
+        
+        if waitClickImg_noWait_withBool([information_img.hero0, information_img.hero1, information_img.hero2], 2, 1):
+            if waitClickImg_noWait_withBool(information_img.gotosee, 2, 1) == False:
+                return False
+            if waitClickImg_noWait_withBool(information_img.explore, 2, 1) == False:
+                return False
+            if waitClickImg_noWait_withBool(information_img.hero_fight, 2, 1) == False:
+                waitClickImg_noWait(information_img.add_strength, 1, 1)
+                waitClickImg_noWait(information_img.add_strength, 1, 1)
+                waitClickImg_noWait(information_img.add_strength, 1, 1)
+                return False
+            
+            myTimeSleep_big()
+            return True
+        elif waitClickImg_noWait_withBool([information_img.camp1, information_img.camp2], 2, 1):
+            if waitClickImg_noWait_withBool(information_img.gotosee, 2, 1) == False:
+                return False
+            if waitClickImg_noWait_withBool(information_img.survive, 2, 1) == False:
+                return False
+            waitClickImg_noWait(information_img.add_strength, 1, 1)
+            waitClickImg_noWait(information_img.add_strength, 1, 1)
+            waitClickImg_noWait(information_img.add_strength, 1, 1)
+            return True
+        elif waitClickImg_noWait_withBool([information_img.wolf0, information_img.wolf1, information_img.wolf2], 2, 1):
+            if waitClickImg_noWait_withBool(information_img.gotosee, 2, 1) == False:
+                return False
+            if waitClickImg_noWait_withBool(information_img.fight, 2, 1) == False:
+                return False
+            if waitClickImg_noWait_withBool(monster_img.line1, 2, 1) == False:
+                return False
+            if waitClickImg_withBool([monster_img.fight, monster_img.fight2], 2, 1) == False:
+                return False
+            waitClickImg_noWait(information_img.add_strength, 1, 1)
+            waitClickImg_noWait(information_img.add_strength, 1, 1)
+            waitClickImg_noWait(information_img.add_strength, 1, 1)
+            return True
+        else:
+            return False
+
+class task_returnAllLine(dongri_task):
+    def __init__(self):
+        super().__init__(f"返回所有路线")
+    def run(self):
+        basic_operate.go_outside()
+        basic_operate.return_line()
+        basic_operate.return_line()
+        basic_operate.return_line()
+        basic_operate.return_line()
+        basic_operate.return_line()
+        basic_operate.return_line()
+        return True
+
+class task_paticipateInTeam(dongri_task):
+    def __init__(self):
+        super().__init__(f"参与队伍")
+    def run(self):
+        basic_operate.go_outside()
+        if waitClickImg_noWait_withBool(check_img.conflits, 2, 1) == False:
+            return False
+        if waitClickImg_noWait_withBool(monster_img.participate, 1, 1) == False:
+            return False
+        
+        while True:
+            if waitClickImg_noWait_withBool(monster_img.line1, 0.1, 1) == False:
+                break
+            if waitFindImg_withBool(monster_img.no_hero, 0.1, 1) == False:
+                break
+            if waitClickImg_noWait_withBool(monster_img.line4, 0.1, 1) == False:
+                break
+            if waitFindImg_withBool(monster_img.no_hero, 0.1, 1) == False:
+                break
+            break
+        
+        waitClickImg_noWait_withBool(monster_img.all_select, 0.1, 1)
+        waitClickImg_noWait_withBool(monster_img.all_select, 0.1, 1)
+
+        maxTryTimes = 3
+        while maxTryTimes > 0:
+            maxTryTimes -= 1
+            waitClickImg_withBool([monster_img.fight, monster_img.fight2], 1, 1)
+            if False == waitClickImg_noWait_withBool(monster_img.all_select, 1, 1):
+                break
+        return True        
+
+
+
+
+if __name__ == '__main__':
+    #basic_operate.go_town()
+    #task_fightMonster(False, True).run()
+    #task_checkHelp().run()
+    #task_checkStoreRoom().run()
+    #task_collect().run()
+    #task_train().run()
+    #task_information().run()
+    #check_buildOrResearch().run()
+    task_checkDonata().run()
+    #task_collect(1).run()
+    #task_collect(2).run()
+    #task_collect(3).run()
+    #task_collect(4).run()
+    #task_returnAllLine().run()
+    #task_paticipateInTeam().run()

+ 13 - 6
scriptBase/comon.py

@@ -158,15 +158,20 @@ def waitClickImg_withBool(imgPath, waitTime, preWaitTime):
     ret, pos = waitClickImg(imgPath, waitTime, preWaitTime)
     return ret
 
-def myTimeSleep(curTime):
+def myTimeSleep(curTime , FunStatus=None):
     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}')
+    while randomTime > 10:
+        time.sleep(10)
+        randomTime -= 10
+        showStr = f'剩余等待时间{randomTime}'
+        if FunStatus is not None:
+            FunStatus(showStr)
+        print(showStr)
     time.sleep(randomTime)
 
+
+
 def myTimeSleep_small():
     time.sleep(random.randint(200, 1000) / 1000)
 
@@ -260,7 +265,9 @@ def getRegion(gamestr, region, 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 game_region():
+    tmpRet, tmpPos = find_window_pos('Mumu模拟器12',)
+    return tmpRet, tmpPos
 
 def yys_getRegion(region, isWidth= False):
     return getRegion('Mumu模拟器12', region, isWidth)

+ 2 - 2
scriptBase/imgFind.py

@@ -103,7 +103,7 @@ class pcacc_img:
     @staticmethod
     def find_img_position(image_path):
         # 设置查找的置信度(confidence)阈值,范围从0到1,默认为0.999
-        confidence_threshold = 0.90
+        confidence_threshold = 0.85
 
         # 查找模糊图片在屏幕上的位置
         position = pyautogui.locateOnScreen(image_path, confidence=confidence_threshold)
@@ -147,7 +147,7 @@ class pcacc_img:
     def find_img(image_path):
 
         # 设置查找的置信度(confidence)阈值,范围从0到1,默认为0.999
-        confidence_threshold = 0.85
+        confidence_threshold = 0.90
 
         # 查找模糊图片在屏幕上的位置
         position = pyautogui.locateOnScreen(image_path, confidence=confidence_threshold)

+ 7 - 0
scriptBase/mouseClick.py

@@ -121,6 +121,13 @@ class pcacc_mouse:
         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 quickclick_current():
+        src_x, src_y = pyautogui.position()
+        win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, src_x + random.randint(-3, 3), src_y + random.randint(-3, 3), 0, 0)
+        time.sleep(1.0 / random.randint(300, 500))
+        win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, src_x + random.randint(-3, 3), src_y + random.randint(-3, 3), 0, 0)
     
     @staticmethod
     def drag_from(src_x, src_y, dst_x, dst_y):

+ 150 - 0
templates/index_dongri.html

@@ -0,0 +1,150 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>yys Display</title>
+    <style>
+        .monitor-container {
+            display: flex;
+            flex-direction: row;
+        }
+        .status-container {
+            display: flex;
+            flex-direction: row;
+        }
+        #hint_message p {
+            font-size: 10px; /* 设置为较小的字体大小 */
+        }
+    </style>
+</head>
+<body>
+    <h2 id="title_message">Monitor Display</h2>
+    <div class="monitor-container">
+        <h3>请选择时间间隔:</h3>
+        <select id="timeInterval">
+            <option value="500">0.5 秒</option>
+            <option value="1000">1 秒</option>
+            <option value="2000">2 秒</option>
+            <option value="5000">5 秒</option>
+            <option value="0">停止</option>
+        </select>
+        <canvas id="canvas" width="520" height="292"></canvas>
+    </div>
+
+    <div class="status-container ">
+        <h3>状态:</h3>
+        <div id="status_message" style="border: 1px solid #ccc; padding: 10px; margin-top: 10px;"></div>
+        <h3>任务列表:</h3>
+        <div id="hint_message"></div>
+        <label><input type="checkbox" id="maxCollectCheckbox"> 是否最大收集</label>
+        <button class="custom-button" id="atuo_btn" onclick="begin_paticipate()">自动集结</button>
+        <button class="custom-button" id="resetScript_btn" onclick="reset_script()">重置脚本</button>
+        <button class="custom-button" id="restartgame_btn" onclick="restart_game()">重新关闭并自动游戏</button>
+        <button class="custom-button" id="atuo_btn" onclick="begin_auto()">自动模式</button>
+    </div>
+    
+    <script src="https://cdnjs.loli.net/ajax/libs/socket.io/4.2.0/socket.io.js"></script>
+    <script>
+
+        const socket = io();
+        socket.on('connect', () => {
+            console.log('Connected to server');
+        });
+        socket.on('disconnect', () => {
+            console.log('Disconnected from server');
+        });
+        socket.on('image_data', (image_data_base64) => {
+            const canvas = document.getElementById('canvas');
+            const ctx = canvas.getContext('2d');
+            const image = new Image();
+            image.onload = () => {
+                ctx.drawImage(image, 0, 0, canvas.width, canvas.height);
+            };
+            image.src = 'data:image/jpeg;base64,' + image_data_base64;
+        });
+        socket.on('processing_status', (msg) => {
+            var messageBox = document.getElementById('status_message');
+            messageBox.innerHTML = msg;
+        });
+        socket.on('processing_title', (msg) => {
+            var messageBox = document.getElementById('title_message');
+            messageBox.innerHTML = msg;
+        });
+        socket.on('processing_hint', (msg) => {
+            var messageBox = document.getElementById('hint_message');
+            var data = JSON.parse(msg);
+            var listDiv = document.createElement("div");
+            for (var i = 0; i < data.length; i++) {
+                var listItem = document.createElement("p");
+                listItem.textContent = data[i];
+                listDiv.appendChild(listItem);
+            }
+            messageBox.innerHTML = "";
+            messageBox.appendChild(listDiv)
+           
+        });
+        var timerId;
+        function executeTask() {
+            var selectElement = document.getElementById("timeInterval");
+            var selectedValue = selectElement.value;
+            if (selectedValue == '0'){
+                clearInterval(timerId)
+                var canvas = document.getElementById("canvas");
+                var ctx = canvas.getContext("2d");
+                ctx.clearRect(0, 0, canvas.width, canvas.height);
+                timerId = setInterval(executeTask, 1000);
+            }
+            else
+            {
+                socket.emit('monitor_begin');
+                clearInterval(timerId)
+                timerId = setInterval(executeTask, parseInt(selectedValue));
+            }
+        }
+
+        function begin_auto() {
+            const isMaxCollect = document.getElementById('maxCollectCheckbox').checked;
+            socket.emit('begin_auto', { maxCollect: isMaxCollect });
+        }
+
+        function begin_paticipate(){
+            socket.emit('begin_auto_participate');
+        }
+        
+        function restart_game()
+        {
+            socket.emit('restart_game');
+        }
+        function get_title()
+        {
+            socket.emit('get_title');
+        }
+
+        function reset_script(){
+            socket.emit('reset_script');
+        }
+        function stopPageAndCloseSocket() {
+            // 停止定时器
+            clearInterval(timerId);
+            // 关闭WebSocket连接
+            socket.disconnect();
+            // 清除画布内容(可选)
+            var canvas = document.getElementById("canvas");
+            var ctx = canvas.getContext("2d");
+            ctx.clearRect(0, 0, canvas.width, canvas.height);
+            // 可以添加其他停止页面运行的逻辑...
+        }
+
+        // 页面加载时设置5分钟后的定时器
+        window.onload = function() {
+            get_title();
+            executeTask();
+            setTimeout(stopPageAndCloseSocket, 120000); // 2分钟 = 120000毫秒
+        };
+        
+    </script>
+</body>
+</html>
+
+