dongguoliang před 2 měsíci
rodič
revize
51fab1bfa9
3 změnil soubory, kde provedl 19 přidání a 13 odebrání
  1. 3 3
      main.py
  2. 14 8
      model/helper.py
  3. 2 2
      tools/emulator/emulator.py

+ 3 - 3
main.py

@@ -63,9 +63,9 @@ def main():
         executor = MyThreadPoolExecutor(max_workers=GM.device_info.window_nums)
         timer = Utils.Timer()
         while GM.get_global_control():
-            if timer.timer('heartbeat', 60):
-                result,message = task_api.heartbeat(GM.device_info.officer)
-                logger.info(f'心跳:{message}')
+            # if timer.timer('heartbeat', 60):
+            #     result,message = task_api.heartbeat(GM.device_info.officer)
+            #     logger.info(f'心跳:{message}')
             idle_worker_count = executor.get_idle_worker_count()
             # 只有当有空闲工作线程时才继续
             if idle_worker_count > 0:

+ 14 - 8
model/helper.py

@@ -13,7 +13,7 @@ from tools.emulator.ld_operate import LD
 from tools.emulator.ys_operate import YS
 from tools.upload_log import LogInfo
 from tools.utils import Utils
-
+from tools.log import logger
 
 @dataclass
 class ScriptHelper:
@@ -152,13 +152,13 @@ class MyHelper:
             # 启动模拟器并确认启动状态
             result, message = self.emu.start_and_confirm(self.emulator_index)
 
-            if result:
-                self.emulator_info = message
-                # 设置模拟器窗口位置
-                self.emu.set_emulator_position(self.emulator_info.top_handle, self.window_id)
-                time.sleep(1)
-                return True, f"模拟器编号:{self.emulator_index},启动成功"
-            return False, f"模拟器编号:{self.emulator_index},,启动失败,错误信息:{message}"
+            # if result:
+            #     self.emulator_info = message
+            #     # 设置模拟器窗口位置
+            #     self.emu.set_emulator_position(self.emulator_info.top_handle, self.window_id)
+            #     time.sleep(1)
+            #     return True, f"模拟器编号:{self.emulator_index},启动成功"
+            # return False, f"模拟器编号:{self.emulator_index},,启动失败,错误信息:{message}"
         except Exception as e:
             return False, f"模拟器编号:{self.emulator_index},启动失败,错误信息:{str(e)}"
 
@@ -217,8 +217,12 @@ class MyHelper:
         Returns:
             tuple: 成功与否的标志和结果或错误信息。
         """
+
+        logger.info(f"进游戏了1",100)
         try:
             if self.game_config.script.endswith('.dll'):
+                logger.info(f"进游戏了3", 100)
+
                 # 获取字符串的字节数据
                 task_id_bytes = self.game_config.task_id.encode('gbk')
                 account_bytes = self.account_info.account.encode('gbk')
@@ -245,6 +249,7 @@ class MyHelper:
                 )
                 return True, result
             elif self.game_config.script.endswith('.py'):
+                logger.info(f"进游戏了2", 100)
                 script_helper = ScriptHelper(dm=self.dm,
                                              emu=self.emu,
                                              emulator_index=self.emulator_index,
@@ -260,6 +265,7 @@ class MyHelper:
                                              timeout=self.game_config.timeout * 60
                                              )
                 result = self.script.execute('script_start_game',script_helper, timeout=30*60)
+                logger.info(f"进游戏了4", 100)
                 return True, result
             else:
                 return False, "脚本文件格式错误"

+ 2 - 2
tools/emulator/emulator.py

@@ -225,12 +225,12 @@ class Emulator:
         in_row = int((pos_index - 1) / max_column) + 1
         x = int(width * (in_column - 1))
         y = int(height * (in_row - 1))
-        # Utils.set_window_position_and_size(emulator_hwnd, x, y, width, height)
+        Utils.set_window_position_and_size(emulator_hwnd, x, y, width, height)
         time.sleep(2)
         for _ in range(retries):
             current_x, current_y, current_width, current_height = Utils.get_window_position_and_size(emulator_hwnd)
             if current_x == x and current_y == y and current_width == width and current_height == height:
                 return True
             time.sleep(2)
-            # Utils.set_window_position_and_size(emulator_hwnd, x, y, width, height)
+            Utils.set_window_position_and_size(emulator_hwnd, x, y, width, height)
         raise Exception(f"Failed to set window position and size after {retries} retries.")