Skip to content

Commit

Permalink
修复某些机器可能后台点击失效的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
ok-oldking committed Sep 26, 2024
1 parent dab35fa commit 63d2f1f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 23 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ok-script==0.0.270
ok-script==0.0.271
#rapidocr_onnxruntime
rapidocr_openvino
pySide6-Fluent-Widgets>=1.5.5
Expand Down
43 changes: 21 additions & 22 deletions src/task/BaseCombatTask.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import math
import time

import cv2
import numpy as np
import win32api

import re
from ok.color.Color import get_connected_area_by_color, color_range_to_bound
Expand Down Expand Up @@ -469,26 +467,27 @@ def in_team(self):
# Function to check if a component forms a ring

def mouse_reset(self):
# logger.debug("mouse_reset")
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)
# # logger.debug("mouse_reset")
# 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)
pass

def count_rings(self, image, color_range, min_area):
# Define the color range
Expand Down

0 comments on commit 63d2f1f

Please sign in to comment.