0
0
mirror of https://github.com/ok-oldking/ok-wuthering-waves.git synced 2025-06-05 08:25:28 +00:00

try catch mouse exception

This commit is contained in:
firedcto@gmail.com 2024-07-16 16:51:11 +08:00
parent b382ceb376
commit 07167cf437

View File

@ -333,22 +333,25 @@ class BaseCombatTask(BaseTask, FindFeature, OCR, CombatCheck):
def mouse_reset(self):
# logger.debug("mouse_reset")
current_position = win32api.GetCursorPos()
if self.mouse_pos:
distance = math.sqrt(
(current_position[0] - self.mouse_pos[0]) ** 2
+ (current_position[1] - self.mouse_pos[1]) ** 2
)
if distance > 400:
logger.debug(f'move mouse back {self.mouse_pos}')
win32api.SetCursorPos(self.mouse_pos)
self.mouse_pos = None
if self.enabled:
self.handler.post(self.mouse_reset, 1)
return
self.mouse_pos = current_position
if self.enabled:
return self.handler.post(self.mouse_reset, 0.005)
try:
current_position = win32api.GetCursorPos()
if self.mouse_pos:
distance = math.sqrt(
(current_position[0] - self.mouse_pos[0]) ** 2
+ (current_position[1] - self.mouse_pos[1]) ** 2
)
if distance > 400:
logger.debug(f'move mouse back {self.mouse_pos}')
win32api.SetCursorPos(self.mouse_pos)
self.mouse_pos = None
if self.enabled:
self.handler.post(self.mouse_reset, 1)
return
self.mouse_pos = current_position
if self.enabled:
return self.handler.post(self.mouse_reset, 0.005)
except Exception as e:
logger.error('mouse_reset exception', e)
white_color = {