runhey / OnmyojiAutoScript

Onmyoji Auto Script | 阴阳师脚本
https://runhey.github.io/OnmyojiAutoScript-website/
GNU General Public License v3.0
1.75k stars 173 forks source link

切换御魂失败导致界面卡死 #494

Open hwef opened 3 weeks ago

hwef commented 3 weeks ago

在提问之前...

描述你的问题

切换御魂中多次切换御魂导致界面卡死

如何复现

  1. 前往 '...'
  2. 点击 '....'
  3. 滑动到 '....'
  4. 出现问题

预期行为

No response

相关 Logs

════════════════════════════════════════════════════════════════════════════════
──────────────────────────────────── OROCHI ────────────────────────────────────
════════════════════════════════════════════════════════════════════════════════
2024-10-12 15:28:41.248 |            script.py:0350 |     INFO | module_path:                                                                                   
H:\game\yys\OnmyojiAutoScript-easy-install\OnmyojiAutoScript-easy-install\tasks\Orochi\script_task.py, module_name: script_task                                 
2024-10-12 15:28:41.288 |           game_ui.py:0097 |     INFO | UI get current page                                                                            
2024-10-12 15:28:41.297 |            logger.py:0284 |     INFO | [UI] page_main                                                                                 
2024-10-12 15:28:41.304 |            logger.py:0276 |     INFO | <<< UI GOTO PAGE_SHIKIGAMI_RECORDS >>>                                                         
2024-10-12 15:28:41.350 |           game_ui.py:0245 |     INFO | Page switch: page_main -> page_shikigami_records                                               
2024-10-12 15:28:41.356 |           control.py:0074 |     INFO | Click (1124,  621) @ PAGE_MAIN_GOTO_SHIKIGAMI_RECORDS                                          
2024-10-12 15:28:43.027 |           game_ui.py:0222 |     INFO | Page arrive: page_shikigami_records                                                            
2024-10-12 15:28:43.519 |           control.py:0074 |     INFO | Click ( 390,   72) @ SS_SOUL_PRESET                                                            
2024-10-12 15:28:44.482 |       switch_soul.py:0061 |     INFO | Click preset in switch soul                                                                    
2024-10-12 15:28:44.487 |            logger.py:0276 |     INFO | <<< SWITCH SOUL BY NAME >>>                                                                    
2024-10-12 15:28:45.162 |            logger.py:0284 |     INFO | [SS_GROUP_NAME 0.246s] ['日常1', '突破2', '御魂3', '斗技4', '寮活动5', '契灵6', '六道椒图7',   
'源赖光']                                                                                                                                                       
2024-10-12 15:28:45.170 |           control.py:0158 |     INFO | Swipe (1208,  196) -> (1186,  328)                                                             
2024-10-12 15:28:48.582 |            logger.py:0284 |     INFO | [SS_GROUP_NAME 0.245s] ['日常1', '突破2', '御魂3', '斗技4', '寮活动5', '契灵6', '六道椒图7',   
'源赖光']                                                                                                                                                       
2024-10-12 15:28:48.590 |       switch_soul.py:0192 |     INFO | Swipe to top of group                                                                          
2024-10-12 15:28:49.269 |            logger.py:0284 |     INFO | [SS_GROUP_NAME 0.248s] ['日常1', '突破2', '御魂3', '斗技4', '寮活动5', '契灵6', '六道椒图7',   
'源赖光']                                                                                                                                                       
2024-10-12 15:28:49.277 |       switch_soul.py:0207 |     INFO | Swipe down to find target group                                                                
2024-10-12 15:28:49.989 |            logger.py:0284 |     INFO | [SS_GROUP_NAME 0.247s] ['日常1', '突破2', '御魂3', '斗技4', '寮活动5', '契灵6', '六道椒图7',   
'源赖光']                                                                                                                                                       
2024-10-12 15:28:49.997 |           sub_ocr.py:0040 |     INFO | OCR [SS_GROUP_NAME] detected in [2]                                                            
2024-10-12 15:28:50.004 |           sub_ocr.py:0059 |     INFO | OCR [SS_GROUP_NAME] detected in (1134.0, 246.0, 65.0, 27.0)                                    
2024-10-12 15:28:50.009 |           control.py:0074 |     INFO | Click (1196,  248) @ SS_GROUP_NAME                                                             
2024-10-12 15:28:50.066 |       switch_soul.py:0215 |     INFO | Select group 御魂3                                                                             
2024-10-12 15:28:50.703 |            logger.py:0284 |     INFO | [SS_TEAM_NAME 0.222s] ['地域鬼王1', '金币2', '石距困28']                                       
2024-10-12 15:28:50.710 |           control.py:0158 |     INFO | Swipe ( 728,  321) -> ( 712,  451)                                                             
2024-10-12 15:28:53.612 |            logger.py:0284 |     INFO | [SS_TEAM_NAME 0.241s] ['魂土', '业原火', '真蛇修>140吞>210']                                   
2024-10-12 15:28:53.619 |           control.py:0158 |     INFO | Swipe ( 710,  314) -> ( 724,  468)                                                             
2024-10-12 15:28:56.519 |            logger.py:0284 |     INFO | [SS_TEAM_NAME 0.240s] ['魂土', '业原火', '真蛇修>140吞>210']                                   
2024-10-12 15:28:56.525 |       switch_soul.py:0229 |     INFO | Swipe to top of team                                                                           
2024-10-12 15:28:57.180 |            logger.py:0284 |     INFO | [SS_TEAM_NAME 0.238s] ['魂土', '业原火', '真蛇修>140吞>210']                                   
2024-10-12 15:28:57.187 |       switch_soul.py:0243 |     INFO | Swipe up to find target team                                                                   
2024-10-12 15:28:57.848 |            logger.py:0284 |     INFO | [SS_TEAM_NAME 0.236s] ['魂土', '业原火', '真蛇修>140吞>210']                                   
2024-10-12 15:28:57.855 |           sub_ocr.py:0040 |     INFO | OCR [SS_TEAM_NAME] detected in [0]                                                             
2024-10-12 15:28:57.860 |           sub_ocr.py:0059 |     INFO | OCR [SS_TEAM_NAME] detected in (577.0, 154.0, 47.0, 25.0)                                      
2024-10-12 15:28:57.865 |           control.py:0074 |     INFO | Click ( 579,  171) @ SS_TEAM_NAME                                                              
2024-10-12 15:28:57.922 |       switch_soul.py:0251 |     INFO | Select team 魂土                                                                               
2024-10-12 15:28:59.378 |            logger.py:0284 |     INFO | [SS_TEAM_NAME 0.237s] ['魂士', '业原火', '真蛇修>140吞>210']                                   
2024-10-12 15:28:59.385 |           sub_ocr.py:0040 |     INFO | OCR [SS_TEAM_NAME] detected in [0]                                                             
2024-10-12 15:28:59.390 |           sub_ocr.py:0059 |     INFO | OCR [SS_TEAM_NAME] detected in (576.0, 163.0, 50.0, 28.0)                                      
2024-10-12 15:28:59.396 |           control.py:0074 |     INFO | Click ( 965,  163) @ SS_TEAM_NAME                                                              
2024-10-12 15:29:00.917 |            logger.py:0284 |     INFO | [SS_TEAM_NAME 0.243s] ['魂土', '业原火', '真蛇修>140吞>210']                                   
2024-10-12 15:29:00.924 |           sub_ocr.py:0040 |     INFO | OCR [SS_TEAM_NAME] detected in [0]                                                             
2024-10-12 15:29:00.929 |           sub_ocr.py:0059 |     INFO | OCR [SS_TEAM_NAME] detected in (577.0, 154.0, 47.0, 25.0)                                      
2024-10-12 15:29:00.935 |           control.py:0074 |     INFO | Click ( 965,  154) @ SS_TEAM_NAME                                                              
2024-10-12 15:29:02.426 |            logger.py:0284 |     INFO | [SS_TEAM_NAME 0.255s] ['魂土', '申须羊羊,铁鼠,照羊羊', '确定']                               
2024-10-12 15:29:02.432 |           sub_ocr.py:0040 |     INFO | OCR [SS_TEAM_NAME] detected in [0]                                                             
2024-10-12 15:29:02.440 |           sub_ocr.py:0059 |     INFO | OCR [SS_TEAM_NAME] detected in (578.0, 154.0, 46.0, 24.0)                                      
2024-10-12 15:29:02.445 |           control.py:0074 |     INFO | Click ( 965,  154) @ SS_TEAM_NAME                                                              
2024-10-12 15:29:03.940 |            logger.py:0284 |     INFO | [SS_TEAM_NAME 0.243s] ['魂土', '申须羊羊,铁鼠,照羊羊', '确定']                               
2024-10-12 15:29:03.946 |           sub_ocr.py:0040 |     INFO | OCR [SS_TEAM_NAME] detected in [0]                                                             
2024-10-12 15:29:03.953 |           sub_ocr.py:0059 |     INFO | OCR [SS_TEAM_NAME] detected in (578.0, 154.0, 46.0, 24.0)                                      
2024-10-12 15:29:03.958 |           control.py:0074 |     INFO | Click ( 965,  154) @ SS_TEAM_NAME                                                              
2024-10-12 15:29:05.454 |            logger.py:0284 |     INFO | [SS_TEAM_NAME 0.258s] ['魂土', '申须羊羊,铁鼠,照羊羊', '确定']                               
2024-10-12 15:29:05.460 |           sub_ocr.py:0040 |     INFO | OCR [SS_TEAM_NAME] detected in [0]                                                             
2024-10-12 15:29:05.464 |           sub_ocr.py:0059 |     INFO | OCR [SS_TEAM_NAME] detected in (578.0, 154.0, 46.0, 24.0)                                      
2024-10-12 15:29:05.471 |           control.py:0074 |     INFO | Click ( 965,  154) @ SS_TEAM_NAME                                                              
2024-10-12 15:29:05.527 |       switch_soul.py:0261 |     INFO | Switch soul_one group 御魂3 team 魂土                                                          
2024-10-12 15:29:05.943 |           game_ui.py:0097 |     INFO | UI get current page                                                                            
2024-10-12 15:29:05.983 |            logger.py:0284 |     INFO | [UI] page_shikigami_records                                                                    
2024-10-12 15:29:05.989 |            logger.py:0276 |     INFO | <<< UI GOTO PAGE_MAIN >>>                                                                      
2024-10-12 15:29:06.009 |           game_ui.py:0245 |     INFO | Page switch: page_shikigami_records -> page_main                                               
2024-10-12 15:29:06.014 |           control.py:0074 |     INFO | Click (  55,   10) @ PAGE_BACK_Y                                                               
2024-10-12 15:29:10.024 |           game_ui.py:0245 |     INFO | Page switch: page_shikigami_records -> page_main                                               
2024-10-12 15:29:10.030 |           control.py:0074 |     INFO | Click (  64,   11) @ PAGE_BACK_Y                                                               
2024-10-12 15:29:14.053 |           game_ui.py:0245 |     INFO | Page switch: page_shikigami_records -> page_main                                               
2024-10-12 15:29:14.058 |           control.py:0074 |     INFO | Click (  58,    7) @ PAGE_BACK_Y                                                               
2024-10-12 15:29:18.122 |           game_ui.py:0245 |     INFO | Page switch: page_shikigami_records -> page_main                                               
2024-10-12 15:29:18.127 |           control.py:0074 |     INFO | Click (  31,   16) @ PAGE_BACK_Y                                                               
2024-10-12 15:29:22.183 |           game_ui.py:0245 |     INFO | Page switch: page_shikigami_records -> page_main                                               
2024-10-12 15:29:22.189 |           control.py:0074 |     INFO | Click (  32,   17) @ PAGE_BACK_Y                                                               
2024-10-12 15:29:26.614 |           game_ui.py:0245 |     INFO | Page switch: page_shikigami_records -> page_main                                               
2024-10-12 15:29:26.619 |           control.py:0074 |     INFO | Click (  34,    9) @ PAGE_BACK_Y                                                               
2024-10-12 15:29:30.693 |           game_ui.py:0245 |     INFO | Page switch: page_shikigami_records -> page_main                                               
2024-10-12 15:29:30.698 |           control.py:0074 |     INFO | Click (  26,   40) @ PAGE_BACK_Y                                                               
2024-10-12 15:29:35.073 |           game_ui.py:0245 |     INFO | Page switch: page_shikigami_records -> page_main                                               
2024-10-12 15:29:35.079 |           control.py:0074 |     INFO | Click (  68,   37) @ PAGE_BACK_Y                                                               
2024-10-12 15:29:39.488 |           game_ui.py:0245 |     INFO | Page switch: page_shikigami_records -> page_main                                               
2024-10-12 15:29:39.493 |            device.py:0191 |  WARNING | Too many click between 2 buttons: SS_TEAM_NAME, PAGE_BACK_Y                                    
2024-10-12 15:29:39.497 |            device.py:0192 |  WARNING | History click: ['SS_TEAM_NAME', 'SS_TEAM_NAME', 'SS_TEAM_NAME', 'SS_TEAM_NAME', 'SS_TEAM_NAME',
'SS_TEAM_NAME', 'PAGE_BACK_Y', 'PAGE_BACK_Y', 'PAGE_BACK_Y', 'PAGE_BACK_Y', 'PAGE_BACK_Y', 'PAGE_BACK_Y', 'PAGE_BACK_Y', 'PAGE_BACK_Y', 'PAGE_BACK_Y']          
2024-10-12 15:29:39.507 |            logger.py:0318 |    ERROR | GameTooManyClickError: Too many click between 2 buttons: SS_TEAM_NAME, PAGE_BACK_Y             
2024-10-12 15:29:39.513 |            script.py:0096 |  WARNING | Saving error: ./log/error/1728718179513

截图

2024-10-12_15-29-39-470352

还有别的吗?

No response

runhey commented 2 weeks ago

源码这里写的不是很好

# 切换御魂
        for i in range(5):
            sleep(0.8)
            self.screenshot()
            self.O_SS_TEAM_NAME.keyword = teamName
            if self.ocr_appear_click_by_rule(self.O_SS_TEAM_NAME, self.I_SOU_CLICK_PRESENT, interval=1):
                continue
            if self.appear_then_click(self.I_SOU_SWITCH_SURE, interval=1):
                break
        logger.info(f'Switch soul_one group {groupName} team {teamName}')
runhey commented 2 weeks ago

改了

hwef commented 2 weeks ago

感觉还是会有问题 点击的时候会点到御魂预设的名称进入编辑界面然后就会跳出 我改了让它选中御魂后多点击几次 修改如下

为什么for k in range(4) 是为了多次兼容更换御魂时的确定和更换契灵的确定 `

切换御魂

    for i in range(5):
        sleep(1)
        self.screenshot()
        self.O_SS_TEAM_NAME.keyword = teamName

        if not is_changed and self.ocr_appear_click_by_rule(self.O_SS_TEAM_NAME, self.I_SOU_CLICK_PRESENT, interval=1)  :
            for k in range(4):
                sleep(0.5)
                self.screenshot()
                self.appear_then_click(self.I_SOU_SWITCH_SURE, interval=1)  

            is_changed = True
            continue

_**def ocr_appear_click_by_rule(self, target: RuleOcr, action: Union[RuleClick, RuleLongClick] = None, interval: float = None, duration: float = None) -> bool: """ ocr识别目标,如果目标存在,则触发动作 :param target: :param action: :param interval: :param duration: :return: """ appear = self.ocr_appear(target, interval)

    if not appear:
        return False

    x1, y1, w1, h1 = target.area
    x, y, w, h = action.roi_back
    for  i in range(3):
        self.device.click(x=x, y=y1, control_name=target.name)
        sleep(0.5)
    return True**_

`

runhey commented 2 weeks ago

没看懂你说的问题,要不录一个视频,