ok-script 0.0.67__tar.gz → 0.0.68__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {ok-script-0.0.67 → ok-script-0.0.68}/PKG-INFO +1 -1
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/capture/HwndWindow.py +9 -3
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/capture/adb/DeviceManager.py +1 -2
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/feature/Box.py +10 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/feature/FeatureSet.py +18 -8
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/feature/FindFeature.py +5 -5
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/gui/debug/DebugTab.py +24 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/gui/debug/FrameWidget.py +36 -4
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/gui/overlay/OverlayWindow.py +9 -4
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/gui/resources.py +367 -381
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/gui/tasks/OneTimeTaskTab.py +1 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/gui/widget/StartLoadingDialog.py +1 -1
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/ocr/OCR.py +27 -7
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/task/ExecutorOperation.py +6 -11
- {ok-script-0.0.67 → ok-script-0.0.68}/ok_script.egg-info/PKG-INFO +1 -1
- {ok-script-0.0.67 → ok-script-0.0.68}/setup.py +1 -1
- {ok-script-0.0.67 → ok-script-0.0.68}/README.md +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/OK.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/__init__.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/alas/__init__.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/alas/emulator_base.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/alas/emulator_windows.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/alas/platform_base.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/alas/platform_windows.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/alas/utils.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/capture/BaseCaptureMethod.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/capture/__init__.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/capture/adb/ADBCaptureMethod.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/capture/adb/StartController.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/capture/adb/WindowsCaptureFactory.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/capture/adb/__init__.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/capture/adb/bin/__init__.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/capture/image/ImageCaptureMethod.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/capture/image/__init__.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/capture/windows/BaseWindowsCaptureMethod.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/capture/windows/BitBltCaptureMethod.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/capture/windows/DesktopDuplicationCaptureMethod.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/capture/windows/WindowsGraphicsCaptureMethod.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/capture/windows/__init__.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/capture/windows/d3d11.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/capture/windows/dump.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/capture/windows/utils.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/capture/windows/window.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/color/Color.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/color/__init__.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/config/Config.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/config/InfoDict.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/config/__init__.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/feature/Feature.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/feature/__init__.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/firebase/FireBaseAnalytics.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/firebase/__init__.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/gui/App.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/gui/Communicate.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/gui/MainWindow.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/gui/MessageWindow.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/gui/TabTitles.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/gui/__init__.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/gui/about/AboutTab.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/gui/about/HttpTextEdit.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/gui/about/VersionCard.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/gui/about/__init__.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/gui/common/OKIcon.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/gui/common/__init__.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/gui/common/config.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/gui/common/style_sheet.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/gui/debug/AspectRatioWidget.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/gui/debug/InfoWidget.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/gui/debug/LoggerWidget.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/gui/debug/Screenshot.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/gui/debug/__init__.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/gui/i18n/__init__.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/gui/i18n/path.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/gui/i18n/update.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/gui/icon/__init__.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/gui/icon/icon.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/gui/overlay/__init__.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/gui/qss/__init__.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/gui/settings/SettingTab.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/gui/settings/__init__.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/gui/start/SelectCaptureListView.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/gui/start/StartCard.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/gui/start/StartTab.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/gui/start/__init__.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/gui/tasks/ConfigItemFactory.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/gui/tasks/ConfigLabelAndWidget.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/gui/tasks/LabelAndDoubleSpinBox.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/gui/tasks/LabelAndDropDown.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/gui/tasks/LabelAndLineEdit.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/gui/tasks/LabelAndList.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/gui/tasks/LabelAndSpinBox.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/gui/tasks/LabelAndSwitchButton.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/gui/tasks/LabelAndWidget.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/gui/tasks/ModifyListDialog.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/gui/tasks/ModifyListItem.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/gui/tasks/StartButton.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/gui/tasks/TaskCard.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/gui/tasks/TaskOpButton.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/gui/tasks/TooltipTableWidget.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/gui/tasks/TriggerTaskTab.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/gui/tasks/__init__.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/gui/util/Alert.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/gui/util/InitWorker.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/gui/util/__init__.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/gui/widget/Card.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/gui/widget/EmptyCard.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/gui/widget/FramelessDialog.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/gui/widget/ListTableWidgetItem.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/gui/widget/NumericTableWidgetItem.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/gui/widget/StatusBar.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/gui/widget/Tab.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/gui/widget/TabWidget.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/gui/widget/UpdateConfigWidgetItem.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/gui/widget/YesNonWidgetItem.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/gui/widget/__init__.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/interaction/ADBInteraction.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/interaction/BaseInteraction.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/interaction/DoNothingInteraction.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/interaction/Win32Interaction.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/interaction/__init__.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/logging/Logger.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/logging/__init__.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/ocr/__init__.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/rotypes/Windows/Foundation/Collections.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/rotypes/Windows/Foundation/__init__.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/rotypes/Windows/Globalization/__init__.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/rotypes/Windows/Graphics/Capture/__init__.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/rotypes/Windows/Graphics/DirectX/Direct3D11/__init__.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/rotypes/Windows/Graphics/DirectX/__init__.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/rotypes/Windows/Graphics/Imaging/__init__.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/rotypes/Windows/Graphics/__init__.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/rotypes/Windows/Media/Ocr/__init__.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/rotypes/Windows/Media/__init__.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/rotypes/Windows/Security/Cryptography/__init__.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/rotypes/Windows/Security/__init__.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/rotypes/Windows/Storage/Streams/__init__.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/rotypes/Windows/Storage/__init__.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/rotypes/Windows/__init__.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/rotypes/__init__.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/rotypes/delegate.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/rotypes/export.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/rotypes/idldsl.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/rotypes/inspectable.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/rotypes/roapi.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/rotypes/types.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/rotypes/winstring.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/save/BlackBarProcessor.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/save/PostProcessor.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/save/SaveByInterval.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/save/SaveByKeyPress.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/save/SaveMethodBase.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/save/__init__.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/scene/FeatureScene.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/scene/Scene.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/scene/__init__.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/stats/StreamStats.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/stats/__init__.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/task/BaseTask.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/task/OneTimeTask.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/task/TaskExecutor.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/task/TriggerTask.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/task/__init__.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/update/GithubMultiDownloader.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/update/Updater.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/update/__init__.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/update/gen_md5.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/util/Handler.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/util/__init__.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/util/exit_event.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/util/json.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/util/list.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/util/path.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/util/thread.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/util/win32_process.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok/util/yaml.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok_script.egg-info/SOURCES.txt +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok_script.egg-info/dependency_links.txt +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok_script.egg-info/requires.txt +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/ok_script.egg-info/top_level.txt +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/setup.cfg +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/tests/__init__.py +0 -0
- {ok-script-0.0.67 → ok-script-0.0.68}/tests/test_updater.py +0 -0
|
@@ -50,8 +50,7 @@ class HwndWindow:
|
|
|
50
50
|
self.title = title
|
|
51
51
|
self.stop_event = threading.Event()
|
|
52
52
|
self.visible = False
|
|
53
|
-
self.
|
|
54
|
-
self.do_update_window_size()
|
|
53
|
+
self.update_window(title, exe_name, frame_width, frame_height)
|
|
55
54
|
self.thread = threading.Thread(target=self.update_window_size, name="update_window_size")
|
|
56
55
|
self.thread.start()
|
|
57
56
|
|
|
@@ -68,14 +67,21 @@ class HwndWindow:
|
|
|
68
67
|
def stop(self):
|
|
69
68
|
self.stop_event.set()
|
|
70
69
|
|
|
70
|
+
def update_window(self, title, exe_name, frame_width, frame_height):
|
|
71
|
+
self.title = title
|
|
72
|
+
self.exe_name = exe_name
|
|
73
|
+
self.update_frame_size(frame_width, frame_height)
|
|
74
|
+
|
|
71
75
|
def update_frame_size(self, width, height):
|
|
72
76
|
logger.debug(f"update_frame_size:{self.frame_width}x{self.frame_height} to {width}x{height}")
|
|
73
77
|
if width != self.frame_width or height != self.frame_height:
|
|
78
|
+
self.hwnd = None
|
|
74
79
|
self.frame_width = width
|
|
75
80
|
self.frame_height = height
|
|
76
81
|
if width > 0 and height > 0:
|
|
77
82
|
self.frame_aspect_ratio = width / height
|
|
78
83
|
logger.debug(f"HwndWindow: frame ratio:{self.frame_aspect_ratio} width: {width}, height: {height}")
|
|
84
|
+
self.do_update_window_size()
|
|
79
85
|
|
|
80
86
|
def update_window_size(self):
|
|
81
87
|
while not self.app_exit_event.is_set() and not self.stop_event.is_set():
|
|
@@ -194,7 +200,7 @@ def find_hwnd(title, exe_name, frame_aspect_ratio=0):
|
|
|
194
200
|
y_offset = ratio_match[5] - biggest[5]
|
|
195
201
|
real_width = ratio_match[2]
|
|
196
202
|
real_height = ratio_match[3]
|
|
197
|
-
logger.debug(f'find_hwnd {results} {biggest} {x_offset, y_offset, real_width, real_height}')
|
|
203
|
+
logger.debug(f'find_hwnd {results} {biggest} {ratio_match} {x_offset, y_offset, real_width, real_height}')
|
|
198
204
|
return biggest[6], biggest[0], biggest[1], x_offset, y_offset, real_width, real_height,
|
|
199
205
|
else:
|
|
200
206
|
return None, None, None, 0, 0, 0, 0
|
|
@@ -204,8 +204,7 @@ class DeviceManager:
|
|
|
204
204
|
if self.hwnd is None:
|
|
205
205
|
self.hwnd = HwndWindow(self.exit_event, title, exe, frame_width, frame_height)
|
|
206
206
|
else:
|
|
207
|
-
self.hwnd.
|
|
208
|
-
self.hwnd.update_title_and_exe(title, exe)
|
|
207
|
+
self.hwnd.update_window(title, exe, frame_width, frame_height)
|
|
209
208
|
|
|
210
209
|
def use_windows_capture(self, override_config=None, require_bg=False, use_bit_blt_only=False):
|
|
211
210
|
if not override_config:
|
|
@@ -250,3 +250,13 @@ def boxes_to_map_by_list_of_names(boxes: list[Box], name_list: list[str]) -> dic
|
|
|
250
250
|
box_dict[box.name] = box
|
|
251
251
|
if len(box_dict) == len(name_list):
|
|
252
252
|
return box_dict
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
def relative_box(frame_width, frame_height, x, y, to_x=1, to_y=1, width=0, height=0, name=None):
|
|
256
|
+
if width == 0:
|
|
257
|
+
width = to_x - x
|
|
258
|
+
if height == 0:
|
|
259
|
+
height = to_y - y
|
|
260
|
+
return Box(int(x * frame_width), int(y * frame_height),
|
|
261
|
+
int(width * frame_width), int(height * frame_height),
|
|
262
|
+
name=name)
|
|
@@ -143,7 +143,8 @@ class FeatureSet:
|
|
|
143
143
|
return boxes[0]
|
|
144
144
|
|
|
145
145
|
def find_feature(self, mat: np.ndarray, category_name: str, horizontal_variance: float = 0,
|
|
146
|
-
vertical_variance: float = 0, threshold: float = 0, use_gray_scale: bool = False
|
|
146
|
+
vertical_variance: float = 0, threshold: float = 0, use_gray_scale: bool = False, x=-1, y=-1,
|
|
147
|
+
to_x=-1, to_y=-1, width=-1, height=-1) -> List[Box]:
|
|
147
148
|
"""
|
|
148
149
|
Find a feature within a given variance.
|
|
149
150
|
|
|
@@ -168,15 +169,24 @@ class FeatureSet:
|
|
|
168
169
|
vertical_variance = self.default_vertical_variance
|
|
169
170
|
if category_name not in self.feature_dict:
|
|
170
171
|
raise ValueError(f"FeatureSet: {category_name} not found in featureDict")
|
|
171
|
-
|
|
172
172
|
feature = self.feature_dict[category_name]
|
|
173
173
|
feature_width, feature_height = feature.width, feature.height
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
174
|
+
if x != -1 and y != -1:
|
|
175
|
+
frame_height, frame_width, *_ = mat.shape
|
|
176
|
+
if width == -1:
|
|
177
|
+
width = to_x - x
|
|
178
|
+
if height == -1:
|
|
179
|
+
height = to_y - y
|
|
180
|
+
search_x1 = int(x * frame_width)
|
|
181
|
+
search_y1 = int(y * frame_height)
|
|
182
|
+
search_x2 = int((x + width) * frame_width)
|
|
183
|
+
search_y2 = int((y + height) * frame_height)
|
|
184
|
+
else:
|
|
185
|
+
# Define search area using variance
|
|
186
|
+
search_x1 = max(0, int(feature.x - self.width * horizontal_variance))
|
|
187
|
+
search_y1 = max(0, int(feature.y - self.height * vertical_variance))
|
|
188
|
+
search_x2 = min(self.width, int(feature.x + feature_width + self.width * horizontal_variance))
|
|
189
|
+
search_y2 = min(self.height, int(feature.y + feature_height + self.height * vertical_variance))
|
|
180
190
|
|
|
181
191
|
search_area = mat[search_y1:search_y2, search_x1:search_x2, :3]
|
|
182
192
|
# Crop the search area from the image
|
|
@@ -11,11 +11,11 @@ class FindFeature:
|
|
|
11
11
|
self.executor = None
|
|
12
12
|
|
|
13
13
|
def find_feature(self, feature_name, horizontal_variance=0, vertical_variance=0, threshold=0,
|
|
14
|
-
use_gray_scale=False) -> List[Box]:
|
|
14
|
+
use_gray_scale=False, x=-1, y=-1, to_x=-1, to_y=-1, width=-1, height=-1) -> List[Box]:
|
|
15
15
|
if self.executor.frame is None:
|
|
16
16
|
return list()
|
|
17
17
|
return self.feature_set.find_feature(self.executor.frame, feature_name, horizontal_variance, vertical_variance,
|
|
18
|
-
threshold, use_gray_scale)
|
|
18
|
+
threshold, use_gray_scale, x, y, to_x, to_y, width, height)
|
|
19
19
|
|
|
20
20
|
def get_box_by_name(self, name):
|
|
21
21
|
return self.feature_set.get_box_by_name(name)
|
|
@@ -33,9 +33,9 @@ class FindFeature:
|
|
|
33
33
|
setattr(self, feature, result)
|
|
34
34
|
return ret
|
|
35
35
|
|
|
36
|
-
def
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
def wait_click_feature(self, feature, horizontal_variance=0, vertical_variance=0, threshold=0, relative_x=0.5,
|
|
37
|
+
relative_y=0.5,
|
|
38
|
+
time_out=0, pre_action=None, post_action=None):
|
|
39
39
|
box = self.wait_until(lambda: self.find_one(feature, horizontal_variance, vertical_variance, threshold),
|
|
40
40
|
time_out,
|
|
41
41
|
pre_action,
|
|
@@ -12,6 +12,7 @@ from ok.gui.util.Alert import alert_info, alert_error
|
|
|
12
12
|
from ok.gui.widget.Tab import Tab
|
|
13
13
|
from ok.interaction.DoNothingInteraction import DoNothingInteraction
|
|
14
14
|
from ok.logging.Logger import get_logger, exception_to_str
|
|
15
|
+
from ok.ocr.OCR import OCR
|
|
15
16
|
from ok.util.Handler import Handler
|
|
16
17
|
|
|
17
18
|
logger = get_logger(__name__)
|
|
@@ -44,6 +45,10 @@ class DebugTab(Tab):
|
|
|
44
45
|
capture_button.clicked.connect(lambda: self.handler.post(self.capture))
|
|
45
46
|
layout.addWidget(capture_button)
|
|
46
47
|
|
|
48
|
+
ocr_button = PushButton("OCR")
|
|
49
|
+
ocr_button.clicked.connect(lambda: self.handler.post(self.ocr))
|
|
50
|
+
layout.addWidget(ocr_button)
|
|
51
|
+
|
|
47
52
|
open_log_folder = PushButton(self.tr("Open Logs"))
|
|
48
53
|
|
|
49
54
|
call_task_widget = QWidget()
|
|
@@ -116,6 +121,25 @@ class DebugTab(Tab):
|
|
|
116
121
|
self.config['target_function'] = func_name
|
|
117
122
|
alert_info(self.tr(f"call success: {result}"))
|
|
118
123
|
|
|
124
|
+
def ocr(self):
|
|
125
|
+
if not ok.gui.executor.ocr:
|
|
126
|
+
alert_error(self.tr('No OCR configured'))
|
|
127
|
+
return
|
|
128
|
+
if ok.gui.device_manager.capture_method is not None:
|
|
129
|
+
logger.info(f'ok.gui.device_manager.capture_method {ok.gui.device_manager.capture_method}')
|
|
130
|
+
capture = str(ok.gui.device_manager.capture_method)
|
|
131
|
+
frame = ok.gui.device_manager.capture_method.do_get_frame()
|
|
132
|
+
if frame is not None:
|
|
133
|
+
ocr = OCR()
|
|
134
|
+
ocr.executor = ok.gui.executor
|
|
135
|
+
result = ocr.ocr(frame=frame)
|
|
136
|
+
self.update_result_text.emit(str(result))
|
|
137
|
+
alert_info(self.tr(f"OCR success: {result}"))
|
|
138
|
+
else:
|
|
139
|
+
alert_error(self.tr('Capture returned None'))
|
|
140
|
+
else:
|
|
141
|
+
alert_error(self.tr('No Capture Available or Selected'))
|
|
142
|
+
|
|
119
143
|
def task_changed(self, text):
|
|
120
144
|
self.config['target_task'] = text
|
|
121
145
|
task = ok.gui.executor.get_task_by_class_name(text)
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import os
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
from PySide6.
|
|
3
|
+
import win32api
|
|
4
|
+
from PySide6.QtCore import Qt, QPoint, QTimer
|
|
5
|
+
from PySide6.QtGui import QPainter, QColor, QPen, QFont, QGuiApplication
|
|
5
6
|
from PySide6.QtWidgets import QWidget
|
|
6
7
|
|
|
7
8
|
import ok.gui
|
|
@@ -14,10 +15,27 @@ logger = get_logger(__name__)
|
|
|
14
15
|
class FrameWidget(QWidget):
|
|
15
16
|
def __init__(self):
|
|
16
17
|
super(FrameWidget, self).__init__()
|
|
17
|
-
|
|
18
18
|
self._visible = True
|
|
19
|
+
self._mouse_position = QPoint(0, 0)
|
|
20
|
+
self.setMouseTracking(True)
|
|
21
|
+
communicate.update_overlay.connect(self.update)
|
|
22
|
+
# Start a timer to update mouse position using Windows API
|
|
23
|
+
self.timer = QTimer(self)
|
|
24
|
+
self.timer.timeout.connect(self.update_mouse_position)
|
|
25
|
+
self.timer.start(1000) # Update every 50 milliseconds
|
|
26
|
+
self.mouse_font = QFont()
|
|
27
|
+
self.mouse_font.setPointSize(10) # Adjust the size as needed
|
|
28
|
+
screen = QGuiApplication.primaryScreen()
|
|
29
|
+
self.scaling = screen.devicePixelRatio()
|
|
19
30
|
communicate.update_overlay.connect(self.update)
|
|
20
31
|
|
|
32
|
+
def update_mouse_position(self):
|
|
33
|
+
x, y = win32api.GetCursorPos()
|
|
34
|
+
relative = self.mapFromGlobal(QPoint(x / self.scaling, y / self.scaling))
|
|
35
|
+
if self._mouse_position != relative and relative.x() > 0 and relative.y() > 0 and self._visible:
|
|
36
|
+
self._mouse_position = relative
|
|
37
|
+
self.update()
|
|
38
|
+
|
|
21
39
|
def frame_ratio(self):
|
|
22
40
|
if ok.gui.device_manager.width == 0:
|
|
23
41
|
return 1
|
|
@@ -29,6 +47,7 @@ class FrameWidget(QWidget):
|
|
|
29
47
|
painter = QPainter(self)
|
|
30
48
|
self.paint_border(painter)
|
|
31
49
|
self.paint_boxes(painter)
|
|
50
|
+
self.paint_mouse_position(painter)
|
|
32
51
|
|
|
33
52
|
def paint_boxes(self, painter):
|
|
34
53
|
pen = QPen() # Set the brush to red color
|
|
@@ -53,6 +72,19 @@ class FrameWidget(QWidget):
|
|
|
53
72
|
pen = QPen(QColor(255, 0, 0, 255)) # Solid red color for the border
|
|
54
73
|
pen.setWidth(1) # Set the border width
|
|
55
74
|
painter.setPen(pen)
|
|
56
|
-
|
|
57
75
|
# Draw the border around the widget
|
|
58
76
|
painter.drawRect(0, 0, self.width() - 1, self.height() - 1)
|
|
77
|
+
|
|
78
|
+
def paint_mouse_position(self, painter):
|
|
79
|
+
x_percent = self._mouse_position.x() / self.width()
|
|
80
|
+
y_percent = self._mouse_position.y() / self.height()
|
|
81
|
+
x, y = self._mouse_position.x() * 2, self._mouse_position.y() * 2
|
|
82
|
+
text = f"({x}, {y}, {x_percent:.2f}, {y_percent:.2f})"
|
|
83
|
+
painter.setFont(self.mouse_font)
|
|
84
|
+
|
|
85
|
+
painter.setPen(QPen(QColor(255, 0, 0, 255), 1))
|
|
86
|
+
painter.drawText(20, 20, text)
|
|
87
|
+
#
|
|
88
|
+
# # Draw the black text
|
|
89
|
+
# painter.setPen(QPen(QColor(0, 0, 0), 2))
|
|
90
|
+
# painter.drawText(10, 10, text)
|
|
@@ -15,15 +15,20 @@ class Communicate(QObject):
|
|
|
15
15
|
class OverlayWindow(FrameWidget):
|
|
16
16
|
def __init__(self, hwnd_window: HwndWindow):
|
|
17
17
|
super().__init__()
|
|
18
|
-
|
|
19
|
-
self.setWindowFlag(Qt.FramelessWindowHint) # Make the window frameless
|
|
18
|
+
# Set translucent background
|
|
20
19
|
self.setAttribute(Qt.WA_TranslucentBackground)
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
|
|
21
|
+
# Ensure mouse events are received properly
|
|
22
|
+
self.setAttribute(Qt.WA_OpaquePaintEvent)
|
|
23
|
+
|
|
24
|
+
# Set window flag to handle mouse events properly with translucent background
|
|
25
|
+
self.setWindowFlags(Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint | Qt.Tool | Qt.WindowTransparentForInput)
|
|
23
26
|
communicate.window.connect(self.update_overlay)
|
|
24
27
|
self.update_overlay(hwnd_window.visible, hwnd_window.x, hwnd_window.y, hwnd_window.border,
|
|
25
28
|
hwnd_window.title_height, hwnd_window.width, hwnd_window.height, hwnd_window.scaling)
|
|
26
29
|
|
|
30
|
+
self.setMouseTracking(True)
|
|
31
|
+
|
|
27
32
|
def update_overlay(self, visible, x, y, border, title_height, width, height, scaling):
|
|
28
33
|
logger.debug(f'update_overlay: {visible}, {x}, {y}, {border}, {title_height} {width}, {height}, {scaling}')
|
|
29
34
|
if visible:
|