ok-script 0.0.89__tar.gz → 0.0.91__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.89 → ok-script-0.0.91}/PKG-INFO +1 -1
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/capture/BaseCaptureMethod.py +0 -10
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/capture/HwndWindow.py +2 -3
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/capture/adb/DeviceManager.py +1 -1
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/capture/adb/WindowsCaptureFactory.py +2 -2
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/capture/windows/BitBltCaptureMethod.py +12 -7
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/capture/windows/WindowsGraphicsCaptureMethod.py +9 -3
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/color/Color.py +34 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/StartController.py +1 -1
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/interaction/BaseInteraction.py +6 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/interaction/Win32Interaction.py +18 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/task/BaseTask.py +0 -1
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/task/ExecutorOperation.py +9 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/task/TaskExecutor.py +2 -2
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/update/Updater.py +1 -1
- {ok-script-0.0.89 → ok-script-0.0.91}/ok_script.egg-info/PKG-INFO +1 -1
- {ok-script-0.0.89 → ok-script-0.0.91}/setup.py +1 -1
- {ok-script-0.0.89 → ok-script-0.0.91}/README.md +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/OK.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/__init__.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/alas/__init__.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/alas/emulator_base.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/alas/emulator_windows.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/alas/platform_base.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/alas/platform_windows.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/alas/utils.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/capture/__init__.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/capture/adb/ADBCaptureMethod.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/capture/adb/__init__.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/capture/adb/bin/__init__.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/capture/image/ImageCaptureMethod.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/capture/image/__init__.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/capture/windows/BaseWindowsCaptureMethod.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/capture/windows/DesktopDuplicationCaptureMethod.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/capture/windows/__init__.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/capture/windows/d3d11.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/capture/windows/dump.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/capture/windows/utils.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/capture/windows/window.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/color/__init__.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/config/Config.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/config/InfoDict.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/config/__init__.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/feature/Box.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/feature/CompressCoco.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/feature/Feature.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/feature/FeatureSet.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/feature/FindFeature.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/feature/__init__.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/firebase/Analytics.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/firebase/__init__.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/App.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/Communicate.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/MainWindow.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/MessageWindow.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/TabTitles.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/__init__.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/about/AboutTab.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/about/HttpTextEdit.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/about/VersionCard.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/about/__init__.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/common/OKIcon.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/common/__init__.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/common/config.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/common/style_sheet.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/debug/AspectRatioWidget.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/debug/DebugTab.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/debug/FrameWidget.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/debug/InfoWidget.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/debug/LogWindow.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/debug/Screenshot.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/debug/__init__.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/i18n/__init__.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/i18n/path.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/i18n/update.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/icon/__init__.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/icon/icon.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/overlay/OverlayWindow.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/overlay/__init__.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/qss/__init__.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/resources.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/settings/SettingTab.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/settings/__init__.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/start/SelectCaptureListView.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/start/StartCard.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/start/StartTab.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/start/__init__.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/tasks/ConfigItemFactory.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/tasks/ConfigLabelAndWidget.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/tasks/LabelAndDoubleSpinBox.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/tasks/LabelAndDropDown.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/tasks/LabelAndLineEdit.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/tasks/LabelAndList.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/tasks/LabelAndSpinBox.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/tasks/LabelAndSwitchButton.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/tasks/LabelAndWidget.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/tasks/ModifyListDialog.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/tasks/ModifyListItem.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/tasks/OneTimeTaskTab.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/tasks/StartButton.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/tasks/TaskCard.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/tasks/TaskOpButton.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/tasks/TooltipTableWidget.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/tasks/TriggerTaskTab.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/tasks/__init__.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/util/Alert.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/util/InitWorker.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/util/__init__.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/widget/Card.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/widget/EmptyCard.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/widget/FramelessDialog.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/widget/ListTableWidgetItem.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/widget/NumericTableWidgetItem.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/widget/StartLoadingDialog.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/widget/StatusBar.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/widget/Tab.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/widget/TabWidget.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/widget/UpdateConfigWidgetItem.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/widget/YesNonWidgetItem.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/gui/widget/__init__.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/interaction/ADBInteraction.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/interaction/DoNothingInteraction.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/interaction/__init__.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/logging/Logger.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/logging/__init__.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/ocr/OCR.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/ocr/__init__.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/rotypes/Windows/Foundation/Collections.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/rotypes/Windows/Foundation/__init__.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/rotypes/Windows/Globalization/__init__.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/rotypes/Windows/Graphics/Capture/__init__.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/rotypes/Windows/Graphics/DirectX/Direct3D11/__init__.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/rotypes/Windows/Graphics/DirectX/__init__.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/rotypes/Windows/Graphics/Imaging/__init__.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/rotypes/Windows/Graphics/__init__.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/rotypes/Windows/Media/Ocr/__init__.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/rotypes/Windows/Media/__init__.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/rotypes/Windows/Security/Cryptography/__init__.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/rotypes/Windows/Security/__init__.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/rotypes/Windows/Storage/Streams/__init__.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/rotypes/Windows/Storage/__init__.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/rotypes/Windows/__init__.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/rotypes/__init__.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/rotypes/delegate.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/rotypes/export.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/rotypes/idldsl.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/rotypes/inspectable.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/rotypes/roapi.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/rotypes/types.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/rotypes/winstring.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/save/BlackBarProcessor.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/save/PostProcessor.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/save/SaveByInterval.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/save/SaveByKeyPress.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/save/SaveMethodBase.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/save/__init__.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/scene/FeatureScene.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/scene/Scene.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/scene/__init__.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/stats/StreamStats.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/stats/__init__.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/task/TriggerTask.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/task/__init__.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/update/GithubMultiDownloader.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/update/__init__.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/update/gen_md5.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/util/Handler.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/util/__init__.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/util/exit_event.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/util/json.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/util/list.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/util/path.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/util/thread.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/util/win32_process.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok/util/yaml.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok_script.egg-info/SOURCES.txt +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok_script.egg-info/dependency_links.txt +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok_script.egg-info/requires.txt +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/ok_script.egg-info/top_level.txt +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/setup.cfg +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/tests/__init__.py +0 -0
- {ok-script-0.0.89 → ok-script-0.0.91}/tests/test_updater.py +0 -0
|
@@ -24,20 +24,10 @@ class BaseCaptureMethod:
|
|
|
24
24
|
|
|
25
25
|
@property
|
|
26
26
|
def width(self):
|
|
27
|
-
if self._size[0] == 0:
|
|
28
|
-
try:
|
|
29
|
-
self.get_frame()
|
|
30
|
-
except Exception as e:
|
|
31
|
-
logger.error('width get frame error', e)
|
|
32
27
|
return self._size[0]
|
|
33
28
|
|
|
34
29
|
@property
|
|
35
30
|
def height(self):
|
|
36
|
-
if self._size[1] == 0:
|
|
37
|
-
try:
|
|
38
|
-
self.get_frame()
|
|
39
|
-
except Exception as e:
|
|
40
|
-
logger.error('height get frame error', e)
|
|
41
31
|
return self._size[1]
|
|
42
32
|
|
|
43
33
|
def get_frame(self) -> np.ndarray | None:
|
|
@@ -178,10 +178,9 @@ def find_hwnd(title, exe_name, frame_width, frame_height, player_id=-1):
|
|
|
178
178
|
|
|
179
179
|
win32gui.EnumWindows(callback, None)
|
|
180
180
|
if len(results) > 0:
|
|
181
|
-
biggest =
|
|
181
|
+
biggest = None
|
|
182
182
|
for result in results:
|
|
183
|
-
|
|
184
|
-
if (biggest is None or (result[2] * result[3]) > biggest[2] * biggest[3]) and bit_blt_test_hwnd(result[0]):
|
|
183
|
+
if biggest is None or (result[2] * result[3]) > biggest[2] * biggest[3]:
|
|
185
184
|
biggest = result
|
|
186
185
|
x_offset = 0
|
|
187
186
|
y_offset = 0
|
|
@@ -268,7 +268,7 @@ class DeviceManager:
|
|
|
268
268
|
width, height = self.get_resolution()
|
|
269
269
|
if self.config.get('capture') == "windows":
|
|
270
270
|
self.ensure_hwnd(None, preferred.get('full_path'), width, height, preferred['player_id'])
|
|
271
|
-
self.use_windows_capture({'can_bit_blt': True}, require_bg=True, use_bit_blt_only=
|
|
271
|
+
self.use_windows_capture({'can_bit_blt': True}, require_bg=True, use_bit_blt_only=False)
|
|
272
272
|
else:
|
|
273
273
|
if not isinstance(self.capture_method, ADBCaptureMethod):
|
|
274
274
|
logger.debug(f'use adb capture')
|
|
@@ -11,10 +11,10 @@ def update_capture_method(config, capture_method, hwnd, require_bg=False, use_bi
|
|
|
11
11
|
from ok.capture.windows.BitBltCaptureMethod import BitBltCaptureMethod
|
|
12
12
|
target_method = BitBltCaptureMethod
|
|
13
13
|
capture_method = get_capture(capture_method, target_method, hwnd)
|
|
14
|
-
if capture_method.
|
|
14
|
+
if capture_method.test_is_not_pure_color():
|
|
15
15
|
return capture_method
|
|
16
16
|
else:
|
|
17
|
-
logger.info("
|
|
17
|
+
logger.info("test_is_not_pure_color failed, can't use BitBlt")
|
|
18
18
|
if use_bit_blt_only:
|
|
19
19
|
return None
|
|
20
20
|
from ok.capture.windows.WindowsGraphicsCaptureMethod import windows_graphics_available
|
|
@@ -10,7 +10,7 @@ from typing_extensions import override
|
|
|
10
10
|
|
|
11
11
|
from ok.capture.windows.BaseWindowsCaptureMethod import BaseWindowsCaptureMethod
|
|
12
12
|
from ok.capture.windows.utils import try_delete_dc, BGRA_CHANNEL_COUNT
|
|
13
|
-
from ok.
|
|
13
|
+
from ok.color.Color import is_close_to_pure_color
|
|
14
14
|
from ok.logging.Logger import get_logger
|
|
15
15
|
|
|
16
16
|
# This is an undocumented nFlag value for PrintWindow
|
|
@@ -60,12 +60,17 @@ class BitBltCaptureMethod(BaseWindowsCaptureMethod):
|
|
|
60
60
|
return False
|
|
61
61
|
return True
|
|
62
62
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
63
|
+
def test_is_not_pure_color(self):
|
|
64
|
+
frame = self.do_get_frame()
|
|
65
|
+
if frame is None:
|
|
66
|
+
logger.error(f'Failed to test_is_not_pure_color frame is None {self.hwnd_window}')
|
|
67
|
+
return False
|
|
68
|
+
else:
|
|
69
|
+
if is_close_to_pure_color(frame):
|
|
70
|
+
logger.error(f'Failed to test_is_not_pure_color failed {self.hwnd_window}')
|
|
71
|
+
return False
|
|
72
|
+
else:
|
|
73
|
+
return True
|
|
69
74
|
|
|
70
75
|
|
|
71
76
|
def bit_blt_capture_frame(hwnd, border, title_height, width, height, ext_left_bounds, ext_top_bounds,
|
|
@@ -39,7 +39,11 @@ class WindowsGraphicsCaptureMethod(BaseWindowsCaptureMethod):
|
|
|
39
39
|
def frame_arrived_callback(self, x, y):
|
|
40
40
|
try:
|
|
41
41
|
self.last_frame_time = time.time()
|
|
42
|
-
|
|
42
|
+
next_frame = self.frame_pool.TryGetNextFrame()
|
|
43
|
+
if next_frame is not None:
|
|
44
|
+
self.last_dx_frame = next_frame
|
|
45
|
+
else:
|
|
46
|
+
logger.warning('frame_arrived_callback TryGetNextFrame returned None')
|
|
43
47
|
except Exception as e:
|
|
44
48
|
logger.error(f"TryGetNextFrame error {e}")
|
|
45
49
|
self.close()
|
|
@@ -47,7 +51,9 @@ class WindowsGraphicsCaptureMethod(BaseWindowsCaptureMethod):
|
|
|
47
51
|
|
|
48
52
|
def convert_dx_frame(self):
|
|
49
53
|
frame = self.last_dx_frame
|
|
54
|
+
self.last_dx_frame = None
|
|
50
55
|
if not frame:
|
|
56
|
+
logger.warning('convert_dx_frame self.last_dx_frame is none')
|
|
51
57
|
return None
|
|
52
58
|
|
|
53
59
|
need_reset_framepool = False
|
|
@@ -93,6 +99,7 @@ class WindowsGraphicsCaptureMethod(BaseWindowsCaptureMethod):
|
|
|
93
99
|
if e.winerror == d3d11.DXGI_ERROR_DEVICE_REMOVED or e.winerror == d3d11.DXGI_ERROR_DEVICE_RESET:
|
|
94
100
|
need_reset_framepool = True
|
|
95
101
|
need_reset_device = True
|
|
102
|
+
logger.error('convert_dx_frame win error', e)
|
|
96
103
|
else:
|
|
97
104
|
raise e
|
|
98
105
|
finally:
|
|
@@ -200,7 +207,6 @@ class WindowsGraphicsCaptureMethod(BaseWindowsCaptureMethod):
|
|
|
200
207
|
frame = self.convert_dx_frame()
|
|
201
208
|
if frame is None:
|
|
202
209
|
return
|
|
203
|
-
self.last_dx_frame = None
|
|
204
210
|
latency = time.time() - self.last_frame_time
|
|
205
211
|
|
|
206
212
|
frame = self.crop_image(frame)
|
|
@@ -210,7 +216,7 @@ class WindowsGraphicsCaptureMethod(BaseWindowsCaptureMethod):
|
|
|
210
216
|
if new_width <= 0 or new_width <= 0:
|
|
211
217
|
logger.warning(f"get_frame size <=0 {new_width}x{new_height}")
|
|
212
218
|
frame = None
|
|
213
|
-
if latency >
|
|
219
|
+
if latency > 2:
|
|
214
220
|
logger.warning(f"latency too large return None frame: {latency}")
|
|
215
221
|
return None
|
|
216
222
|
else:
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from collections import defaultdict
|
|
3
|
+
|
|
1
4
|
import cv2
|
|
2
5
|
import numpy as np
|
|
3
6
|
|
|
@@ -16,6 +19,29 @@ white_color = {
|
|
|
16
19
|
}
|
|
17
20
|
|
|
18
21
|
|
|
22
|
+
def is_close_to_pure_color(image, max_colors=5000, percent=0.97):
|
|
23
|
+
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
|
|
24
|
+
|
|
25
|
+
# Step 2: Initialize a dictionary to count color frequencies
|
|
26
|
+
color_counts = defaultdict(int)
|
|
27
|
+
# Step 3: Go through each pixel and count
|
|
28
|
+
for row in image:
|
|
29
|
+
for pixel in row:
|
|
30
|
+
# Convert the pixel tuple to a hashable type for counting
|
|
31
|
+
color = tuple(pixel)
|
|
32
|
+
color_counts[color] += 1
|
|
33
|
+
if len(color_counts) > max_colors:
|
|
34
|
+
return False
|
|
35
|
+
|
|
36
|
+
# Step 4: Find the most dominant color and its percentage
|
|
37
|
+
dominant_color = max(color_counts, key=color_counts.get)
|
|
38
|
+
dominant_count = color_counts[dominant_color]
|
|
39
|
+
total_pixels = image.shape[0] * image.shape[1]
|
|
40
|
+
percentage = (dominant_count / total_pixels)
|
|
41
|
+
|
|
42
|
+
return percentage > percent
|
|
43
|
+
|
|
44
|
+
|
|
19
45
|
def calculate_colorfulness(image, box=None):
|
|
20
46
|
if box is not None:
|
|
21
47
|
image = image[box.y:box.y + box.height, box.x:box.x + box.width, :3]
|
|
@@ -146,3 +172,11 @@ def calculate_color_percentage(image, color_ranges, box=None):
|
|
|
146
172
|
total_pixels = image.size / 3 # Divide by 3 for an RGB image
|
|
147
173
|
percentage = target_pixels / total_pixels
|
|
148
174
|
return percentage
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
if __name__ == '__main__':
|
|
178
|
+
file = 'C:\\Users\\ok\Downloads\\ok-baijing (2)\\screenshots\\1.png'
|
|
179
|
+
exists = os.path.exists(file)
|
|
180
|
+
image = cv2.imread(file
|
|
181
|
+
)
|
|
182
|
+
print(is_close_to_pure_color(image))
|
|
@@ -83,7 +83,7 @@ class StartController(QObject):
|
|
|
83
83
|
"Game resolution {resolution} is not supported").format(resolution=resolution)
|
|
84
84
|
if supported_ratio:
|
|
85
85
|
error += self.tr(', the supported ratio is {supported_ratio}').format(supported_ratio=supported_ratio)
|
|
86
|
-
if
|
|
86
|
+
if min_size:
|
|
87
87
|
error += self.tr(', the supported min resolution is {min_size}').format(
|
|
88
88
|
min_size=f'{min_size[0]}x{min_size[1]}')
|
|
89
89
|
error += self.tr(', check if game windows is minimized, resized or out of screen.')
|
|
@@ -34,3 +34,9 @@ class BaseInteraction:
|
|
|
34
34
|
logger.debug(f"click {x, y}")
|
|
35
35
|
else:
|
|
36
36
|
logger.debug(f"click {name} {x, y}")
|
|
37
|
+
|
|
38
|
+
def right_click(self, x=-1, y=-1, move_back=False, name=None):
|
|
39
|
+
if name is None:
|
|
40
|
+
logger.debug(f"right_click {x, y}")
|
|
41
|
+
else:
|
|
42
|
+
logger.debug(f"right_click {name} {x, y}")
|
|
@@ -95,6 +95,24 @@ class Win32Interaction(BaseInteraction):
|
|
|
95
95
|
if current_x != -1 and current_y != -1:
|
|
96
96
|
pydirectinput.moveTo(current_x, current_y)
|
|
97
97
|
|
|
98
|
+
def right_click(self, x=-1, y=-1, move_back=False, name=None):
|
|
99
|
+
super().right_click(x, y, name=name)
|
|
100
|
+
if not self.capture.clickable():
|
|
101
|
+
logger.info(f"window in background, not clickable")
|
|
102
|
+
return
|
|
103
|
+
# Convert the x, y position to lParam
|
|
104
|
+
# lParam = win32api.MAKELONG(x, y)
|
|
105
|
+
current_x, current_y = -1, -1
|
|
106
|
+
if move_back:
|
|
107
|
+
current_x, current_y = pydirectinput.position()
|
|
108
|
+
if x != -1 and y != -1:
|
|
109
|
+
x, y = self.capture.get_abs_cords(x, y)
|
|
110
|
+
logger.info(f"left_click {x, y}")
|
|
111
|
+
pydirectinput.moveTo(x, y)
|
|
112
|
+
pydirectinput.rightClick()
|
|
113
|
+
if current_x != -1 and current_y != -1:
|
|
114
|
+
pydirectinput.moveTo(current_x, current_y)
|
|
115
|
+
|
|
98
116
|
def mouse_down(self, x=-1, y=-1, name=None):
|
|
99
117
|
if not self.capture.clickable():
|
|
100
118
|
logger.info(f"window in background, not clickable")
|
|
@@ -57,6 +57,12 @@ class ExecutorOperation:
|
|
|
57
57
|
self.executor.reset_scene()
|
|
58
58
|
self.executor.interaction.mouse_up()
|
|
59
59
|
|
|
60
|
+
def right_click(self, x=-1, y=-1, move_back=False, name=None):
|
|
61
|
+
communicate.emit_draw_box("right_click", [Box(max(0, x - 10), max(0, y - 10), 20, 20, name="right_click")],
|
|
62
|
+
"green")
|
|
63
|
+
self.executor.reset_scene()
|
|
64
|
+
self.executor.interaction.right_click(x, y, move_back, name=name)
|
|
65
|
+
|
|
60
66
|
def swipe_relative(self, from_x, from_y, to_x, to_y, duration=0.5):
|
|
61
67
|
self.swipe(int(self.width * from_x), int(self.height * from_y), int(self.width * to_x),
|
|
62
68
|
int(self.height * to_y), duration)
|
|
@@ -156,6 +162,9 @@ class ExecutorOperation:
|
|
|
156
162
|
self.executor.sleep(timeout)
|
|
157
163
|
|
|
158
164
|
def send_key(self, key, down_time=0.02):
|
|
165
|
+
frame = self.executor.nullable_frame()
|
|
166
|
+
communicate.emit_draw_box("send_key", [Box(max(0, 0), max(0, 0), 20, 20, name="send_key_" + str(key))], "green",
|
|
167
|
+
frame)
|
|
159
168
|
self.executor.reset_scene()
|
|
160
169
|
self.executor.interaction.send_key(key, down_time)
|
|
161
170
|
|
|
@@ -76,11 +76,11 @@ class TaskExecutor:
|
|
|
76
76
|
|
|
77
77
|
def check_frame_and_resolution(self, supported_ratio, min_size):
|
|
78
78
|
if supported_ratio is None or min_size is None:
|
|
79
|
-
return True,
|
|
79
|
+
return True, '0x0'
|
|
80
80
|
self.device_manager.update_resolution_for_hwnd()
|
|
81
81
|
frame = self.method.get_frame()
|
|
82
82
|
if frame is None:
|
|
83
|
-
return False,
|
|
83
|
+
return False, '0x0'
|
|
84
84
|
width = self.method.width
|
|
85
85
|
height = self.method.height
|
|
86
86
|
if height == 0:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ok-script-0.0.89 → ok-script-0.0.91}/ok/rotypes/Windows/Graphics/DirectX/Direct3D11/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|