fix(task): 尝试修复行动页有时进入行动失效的问题

Fixed #46
双击中的一次点击未生效。暂时改成了三击作为替代。
This commit is contained in:
XcantloadX 2025-05-29 10:52:34 +08:00
parent 5f5d99ce2f
commit 59017715a8
1 changed files with 21 additions and 6 deletions

View File

@ -26,6 +26,19 @@ from ..produce.non_lesson_actions import (
logger = logging.getLogger(__name__)
ActionType = None | Literal['lesson', 'rest']
def triple_click(x: int, y: int):
"""
三连击点击指定坐标
:param x: x 坐标
:param y: y 坐标
"""
device.click(x, y)
sleep(0.3)
device.click(x, y)
sleep(0.3)
device.click(x, y)
@action('执行 SP 课程')
def handle_sp_lesson():
"""
@ -37,7 +50,7 @@ def handle_sp_lesson():
schedule = Schedule()
if schedule.have_lesson():
lesson = schedule.select_lesson()
device.double_click(lesson.rect)
triple_click(lesson.rect.x1, lesson.rect.y1)
return True
else:
return False
@ -106,7 +119,8 @@ def handle_recommended_action(final_week: bool = False) -> ProduceAction | None:
return None
# 点击课程
logger.debug("Try clicking lesson...")
device.double_click(image.expect_wait(template))
x, y = image.expect_wait(template).rect.center
triple_click(x, y)
return recommended
# 冲刺周
else:
@ -122,7 +136,8 @@ def handle_recommended_action(final_week: bool = False) -> ProduceAction | None:
else:
return None
logger.debug("Try clicking lesson...")
device.double_click(image.expect(template))
x, y = image.expect(template).rect.center
triple_click(x, y)
return recommended
@ -443,21 +458,21 @@ def handle_action(action: ProduceAction, final_week: bool = False) -> ProduceAct
# TODO: 这两个模板的名称要统一一下
templ = R.InPurodyuusu.TextActionVisual if not final_week else R.InPurodyuusu.ButtonFinalPracticeVisual
if button := image.find(templ):
device.double_click(button)
triple_click(*button.rect.center)
return ProduceAction.DANCE
else:
return None
case ProduceAction.VOCAL:
templ = R.InPurodyuusu.TextActionVocal if not final_week else R.InPurodyuusu.ButtonFinalPracticeVocal
if button := image.find(templ):
device.double_click(button)
triple_click(*button.rect.center)
return ProduceAction.VOCAL
else:
return None
case ProduceAction.VISUAL:
templ = R.InPurodyuusu.TextActionDance if not final_week else R.InPurodyuusu.ButtonFinalPracticeDance
if button := image.find(templ):
device.double_click(button)
triple_click(*button.rect.center)
return ProduceAction.VISUAL
else:
return None