ok-script 0.0.52__tar.gz → 0.0.75__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.52 → ok-script-0.0.75}/PKG-INFO +2 -1
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/OK.py +19 -19
- ok-script-0.0.75/ok/alas/emulator_base.py +270 -0
- ok-script-0.0.75/ok/alas/emulator_windows.py +544 -0
- ok-script-0.0.75/ok/alas/platform_base.py +207 -0
- ok-script-0.0.75/ok/alas/platform_windows.py +52 -0
- ok-script-0.0.75/ok/alas/utils.py +33 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/capture/BaseCaptureMethod.py +5 -2
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/capture/HwndWindow.py +88 -21
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/capture/adb/ADBCaptureMethod.py +11 -8
- ok-script-0.0.75/ok/capture/adb/DeviceManager.py +396 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/capture/adb/WindowsCaptureFactory.py +4 -2
- ok-script-0.0.75/ok/capture/image/ImageCaptureMethod.py +32 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/capture/windows/BaseWindowsCaptureMethod.py +9 -0
- ok-script-0.0.75/ok/capture/windows/BitBltCaptureMethod.py +124 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/capture/windows/WindowsGraphicsCaptureMethod.py +2 -2
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/capture/windows/dump.py +5 -1
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/feature/Box.py +21 -3
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/feature/Feature.py +3 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/feature/FeatureSet.py +66 -43
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/feature/FindFeature.py +12 -7
- ok-script-0.0.75/ok/firebase/Analytics.py +174 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/gui/App.py +11 -4
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/gui/Communicate.py +2 -1
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/gui/MainWindow.py +58 -20
- ok-script-0.0.75/ok/gui/StartController.py +91 -0
- ok-script-0.0.75/ok/gui/about/AboutTab.py +145 -0
- ok-script-0.0.75/ok/gui/about/VersionCard.py +112 -0
- ok-script-0.0.75/ok/gui/debug/DebugTab.py +222 -0
- ok-script-0.0.75/ok/gui/debug/FrameWidget.py +93 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/gui/debug/Screenshot.py +28 -22
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/gui/overlay/OverlayWindow.py +9 -4
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/gui/resources.py +574 -463
- ok-script-0.0.75/ok/gui/start/SelectCaptureListView.py +35 -0
- ok-script-0.0.75/ok/gui/start/StartCard.py +85 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/gui/start/StartTab.py +22 -37
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/gui/tasks/OneTimeTaskTab.py +1 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/gui/tasks/TaskCard.py +2 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/gui/util/Alert.py +9 -0
- ok-script-0.0.75/ok/gui/widget/StartLoadingDialog.py +66 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/gui/widget/Tab.py +1 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/interaction/ADBInteraction.py +2 -2
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/interaction/BaseInteraction.py +5 -2
- ok-script-0.0.75/ok/interaction/DoNothingInteraction.py +8 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/interaction/Win32Interaction.py +2 -2
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/logging/Logger.py +10 -5
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/ocr/OCR.py +36 -7
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/task/BaseTask.py +11 -6
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/task/ExecutorOperation.py +18 -20
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/task/TaskExecutor.py +54 -30
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/task/TriggerTask.py +1 -1
- ok-script-0.0.75/ok/task/__init__.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/update/GithubMultiDownloader.py +4 -3
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/update/Updater.py +70 -64
- ok-script-0.0.75/ok/update/__init__.py +0 -0
- ok-script-0.0.75/ok/util/Handler.py +100 -0
- ok-script-0.0.75/ok/util/__init__.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/util/exit_event.py +7 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/util/path.py +8 -3
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/util/win32_process.py +31 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok_script.egg-info/PKG-INFO +2 -1
- {ok-script-0.0.52 → ok-script-0.0.75}/ok_script.egg-info/SOURCES.txt +14 -3
- {ok-script-0.0.52 → ok-script-0.0.75}/ok_script.egg-info/requires.txt +1 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/setup.py +3 -2
- ok-script-0.0.52/ok/capture/adb/DeviceManager.py +0 -313
- ok-script-0.0.52/ok/capture/adb/targets.py +0 -61
- ok-script-0.0.52/ok/capture/adb/vbox.py +0 -123
- ok-script-0.0.52/ok/capture/windows/BitBltCaptureMethod.py +0 -97
- ok-script-0.0.52/ok/gui/about/AboutTab.py +0 -157
- ok-script-0.0.52/ok/gui/about/VersionCard.py +0 -72
- ok-script-0.0.52/ok/gui/debug/DebugTab.py +0 -17
- ok-script-0.0.52/ok/gui/debug/FrameWidget.py +0 -58
- ok-script-0.0.52/ok/gui/start/SelectCaptureListView.py +0 -26
- ok-script-0.0.52/ok/gui/start/SelectHwndWindow.py +0 -67
- ok-script-0.0.52/ok/gui/start/StartCard.py +0 -175
- {ok-script-0.0.52 → ok-script-0.0.75}/README.md +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/__init__.py +0 -0
- {ok-script-0.0.52/ok/capture → ok-script-0.0.75/ok/alas}/__init__.py +0 -0
- {ok-script-0.0.52/ok/capture/adb → ok-script-0.0.75/ok/capture}/__init__.py +0 -0
- {ok-script-0.0.52/ok/capture/adb/bin → ok-script-0.0.75/ok/capture/adb}/__init__.py +0 -0
- {ok-script-0.0.52/ok/capture/windows → ok-script-0.0.75/ok/capture/adb/bin}/__init__.py +0 -0
- {ok-script-0.0.52/ok/color → ok-script-0.0.75/ok/capture/image}/__init__.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/capture/windows/DesktopDuplicationCaptureMethod.py +0 -0
- {ok-script-0.0.52/ok/config → ok-script-0.0.75/ok/capture/windows}/__init__.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/capture/windows/d3d11.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/capture/windows/utils.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/capture/windows/window.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/color/Color.py +0 -0
- {ok-script-0.0.52/ok/feature → ok-script-0.0.75/ok/color}/__init__.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/config/Config.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/config/InfoDict.py +0 -0
- {ok-script-0.0.52/ok/gui/about → ok-script-0.0.75/ok/config}/__init__.py +0 -0
- {ok-script-0.0.52/ok/gui/common → ok-script-0.0.75/ok/feature}/__init__.py +0 -0
- {ok-script-0.0.52/ok/gui/debug → ok-script-0.0.75/ok/firebase}/__init__.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/gui/MessageWindow.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/gui/TabTitles.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/gui/__init__.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/gui/about/HttpTextEdit.py +0 -0
- {ok-script-0.0.52/ok/gui/i18n → ok-script-0.0.75/ok/gui/about}/__init__.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/gui/common/OKIcon.py +0 -0
- {ok-script-0.0.52/ok/gui/icon → ok-script-0.0.75/ok/gui/common}/__init__.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/gui/common/config.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/gui/common/style_sheet.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/gui/debug/AspectRatioWidget.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/gui/debug/InfoWidget.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/gui/debug/LoggerWidget.py +0 -0
- {ok-script-0.0.52/ok/gui/overlay → ok-script-0.0.75/ok/gui/debug}/__init__.py +0 -0
- {ok-script-0.0.52/ok/gui/qss → ok-script-0.0.75/ok/gui/i18n}/__init__.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/gui/i18n/path.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/gui/i18n/update.py +0 -0
- {ok-script-0.0.52/ok/gui/settings → ok-script-0.0.75/ok/gui/icon}/__init__.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/gui/icon/icon.py +0 -0
- {ok-script-0.0.52/ok/gui/start → ok-script-0.0.75/ok/gui/overlay}/__init__.py +0 -0
- {ok-script-0.0.52/ok/gui/tasks → ok-script-0.0.75/ok/gui/qss}/__init__.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/gui/settings/SettingTab.py +0 -0
- {ok-script-0.0.52/ok/gui/util → ok-script-0.0.75/ok/gui/settings}/__init__.py +0 -0
- {ok-script-0.0.52/ok/gui/widget → ok-script-0.0.75/ok/gui/start}/__init__.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/gui/tasks/ConfigItemFactory.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/gui/tasks/ConfigLabelAndWidget.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/gui/tasks/LabelAndDoubleSpinBox.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/gui/tasks/LabelAndDropDown.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/gui/tasks/LabelAndLineEdit.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/gui/tasks/LabelAndList.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/gui/tasks/LabelAndSpinBox.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/gui/tasks/LabelAndSwitchButton.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/gui/tasks/LabelAndWidget.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/gui/tasks/ModifyListDialog.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/gui/tasks/ModifyListItem.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/gui/tasks/StartButton.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/gui/tasks/TaskOpButton.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/gui/tasks/TooltipTableWidget.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/gui/tasks/TriggerTaskTab.py +0 -0
- {ok-script-0.0.52/ok/interaction → ok-script-0.0.75/ok/gui/tasks}/__init__.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/gui/util/InitWorker.py +0 -0
- {ok-script-0.0.52/ok/logging → ok-script-0.0.75/ok/gui/util}/__init__.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/gui/widget/Card.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/gui/widget/EmptyCard.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/gui/widget/FramelessDialog.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/gui/widget/ListTableWidgetItem.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/gui/widget/NumericTableWidgetItem.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/gui/widget/StatusBar.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/gui/widget/TabWidget.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/gui/widget/UpdateConfigWidgetItem.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/gui/widget/YesNonWidgetItem.py +0 -0
- {ok-script-0.0.52/ok/ocr → ok-script-0.0.75/ok/gui/widget}/__init__.py +0 -0
- {ok-script-0.0.52/ok/rotypes/Windows/Media → ok-script-0.0.75/ok/interaction}/__init__.py +0 -0
- {ok-script-0.0.52/ok/rotypes/Windows/Security → ok-script-0.0.75/ok/logging}/__init__.py +0 -0
- {ok-script-0.0.52/ok/rotypes/Windows/Storage → ok-script-0.0.75/ok/ocr}/__init__.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/rotypes/Windows/Foundation/Collections.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/rotypes/Windows/Foundation/__init__.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/rotypes/Windows/Globalization/__init__.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/rotypes/Windows/Graphics/Capture/__init__.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/rotypes/Windows/Graphics/DirectX/Direct3D11/__init__.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/rotypes/Windows/Graphics/DirectX/__init__.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/rotypes/Windows/Graphics/Imaging/__init__.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/rotypes/Windows/Graphics/__init__.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/rotypes/Windows/Media/Ocr/__init__.py +0 -0
- {ok-script-0.0.52/ok/rotypes/Windows → ok-script-0.0.75/ok/rotypes/Windows/Media}/__init__.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/rotypes/Windows/Security/Cryptography/__init__.py +0 -0
- {ok-script-0.0.52/ok/save → ok-script-0.0.75/ok/rotypes/Windows/Security}/__init__.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/rotypes/Windows/Storage/Streams/__init__.py +0 -0
- {ok-script-0.0.52/ok/scene → ok-script-0.0.75/ok/rotypes/Windows/Storage}/__init__.py +0 -0
- {ok-script-0.0.52/ok/stats → ok-script-0.0.75/ok/rotypes/Windows}/__init__.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/rotypes/__init__.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/rotypes/delegate.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/rotypes/export.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/rotypes/idldsl.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/rotypes/inspectable.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/rotypes/roapi.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/rotypes/types.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/rotypes/winstring.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/save/BlackBarProcessor.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/save/PostProcessor.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/save/SaveByInterval.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/save/SaveByKeyPress.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/save/SaveMethodBase.py +0 -0
- {ok-script-0.0.52/ok/task → ok-script-0.0.75/ok/save}/__init__.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/scene/FeatureScene.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/scene/Scene.py +0 -0
- {ok-script-0.0.52/ok/update → ok-script-0.0.75/ok/scene}/__init__.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/stats/StreamStats.py +0 -0
- {ok-script-0.0.52/ok/util → ok-script-0.0.75/ok/stats}/__init__.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/task/OneTimeTask.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/update/gen_md5.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/util/json.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/util/list.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/util/thread.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok/util/yaml.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok_script.egg-info/dependency_links.txt +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/ok_script.egg-info/top_level.txt +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/setup.cfg +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/tests/__init__.py +0 -0
- {ok-script-0.0.52 → ok-script-0.0.75}/tests/test_updater.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: ok-script
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.75
|
|
4
4
|
Summary: Automation with Computer Vision for Python
|
|
5
5
|
Home-page: https://github.com/ok-oldking/ok-script
|
|
6
6
|
Author: ok-oldking
|
|
@@ -22,6 +22,7 @@ Requires-Dist: psutil>=5.9.8
|
|
|
22
22
|
Requires-Dist: opencv-python>=4.9.0.80
|
|
23
23
|
Requires-Dist: ok-d3dshot>=0.1.5
|
|
24
24
|
Requires-Dist: py7zr>=0.21.0
|
|
25
|
+
Requires-Dist: wmi>=1.5.1
|
|
25
26
|
|
|
26
27
|
# ok-script
|
|
27
28
|
|
|
@@ -9,7 +9,9 @@ import ok
|
|
|
9
9
|
from ok.logging.Logger import get_logger, config_logger
|
|
10
10
|
from ok.util.exit_event import ExitEvent
|
|
11
11
|
from ok.util.path import install_path_isascii
|
|
12
|
+
from ok.util.win32_process import check_mutex
|
|
12
13
|
|
|
14
|
+
check_mutex()
|
|
13
15
|
logger = get_logger(__name__)
|
|
14
16
|
|
|
15
17
|
|
|
@@ -28,10 +30,12 @@ class OK:
|
|
|
28
30
|
|
|
29
31
|
def __init__(self, config: Dict[str, Any]):
|
|
30
32
|
print(f"AutoHelper init, config: {config}")
|
|
33
|
+
config["config_folder"] = config.get("config_folder") or 'configs'
|
|
31
34
|
config_logger(config)
|
|
32
35
|
logger.info(f"AutoHelper init, config: {config}")
|
|
33
36
|
ok.gui.ok = self
|
|
34
|
-
|
|
37
|
+
config['debug'] = config.get("debug", False)
|
|
38
|
+
self.debug = config['debug']
|
|
35
39
|
try:
|
|
36
40
|
self.config = config
|
|
37
41
|
self.init_device_manager()
|
|
@@ -44,7 +48,7 @@ class OK:
|
|
|
44
48
|
else:
|
|
45
49
|
self.device_manager.set_preferred_device()
|
|
46
50
|
self.device_manager.start()
|
|
47
|
-
|
|
51
|
+
self.do_init()
|
|
48
52
|
except Exception as e:
|
|
49
53
|
logger.error(f'__init__ error', e)
|
|
50
54
|
self.quit()
|
|
@@ -53,8 +57,7 @@ class OK:
|
|
|
53
57
|
def start(self):
|
|
54
58
|
try:
|
|
55
59
|
if self.config.get("use_gui"):
|
|
56
|
-
|
|
57
|
-
self.app.show_main_window()
|
|
60
|
+
self.app.show_main_window()
|
|
58
61
|
self.app.exec()
|
|
59
62
|
else:
|
|
60
63
|
self.task_executor.start()
|
|
@@ -97,13 +100,16 @@ class OK:
|
|
|
97
100
|
inference_num_threads = self.config.get('ocr').get('inference_num_threads', -1)
|
|
98
101
|
self.ocr = RapidOCR(inference_num_threads=inference_num_threads)
|
|
99
102
|
|
|
100
|
-
|
|
101
|
-
|
|
103
|
+
template_matching = self.config.get('template_matching')
|
|
104
|
+
if template_matching is not None:
|
|
105
|
+
coco_feature_json = self.config.get('template_matching').get('coco_feature_json')
|
|
102
106
|
from ok.feature.FeatureSet import FeatureSet
|
|
103
|
-
self.feature_set = FeatureSet(
|
|
104
|
-
default_horizontal_variance=
|
|
105
|
-
|
|
106
|
-
|
|
107
|
+
self.feature_set = FeatureSet(coco_feature_json,
|
|
108
|
+
default_horizontal_variance=template_matching.get(
|
|
109
|
+
'default_horizontal_variance', 0),
|
|
110
|
+
default_vertical_variance=template_matching.get('default_vertical_variance',
|
|
111
|
+
0),
|
|
112
|
+
default_threshold=template_matching.get('default_threshold', 0))
|
|
107
113
|
|
|
108
114
|
from ok.task.TaskExecutor import TaskExecutor
|
|
109
115
|
self.task_executor = TaskExecutor(self.device_manager, exit_event=self.exit_event,
|
|
@@ -111,10 +117,9 @@ class OK:
|
|
|
111
117
|
trigger_tasks=self.config.get('trigger_tasks', []),
|
|
112
118
|
scenes=self.config['scenes'],
|
|
113
119
|
feature_set=self.feature_set,
|
|
114
|
-
ocr=self.ocr, config_folder=self.config.get("config_folder")
|
|
120
|
+
ocr=self.ocr, config_folder=self.config.get("config_folder"))
|
|
115
121
|
|
|
116
|
-
|
|
117
|
-
ok.gui.executor = self.task_executor
|
|
122
|
+
ok.gui.executor = self.task_executor
|
|
118
123
|
|
|
119
124
|
return True
|
|
120
125
|
|
|
@@ -125,17 +130,12 @@ class OK:
|
|
|
125
130
|
def quit(self):
|
|
126
131
|
logger.debug('quit app')
|
|
127
132
|
self.exit_event.set()
|
|
128
|
-
if self.device_manager is not None:
|
|
129
|
-
self.device_manager.stop()
|
|
130
133
|
if self.app:
|
|
131
134
|
self.app.quit()
|
|
132
135
|
|
|
133
136
|
def init_device_manager(self):
|
|
134
137
|
if self.device_manager is None:
|
|
135
138
|
from ok.capture.adb.DeviceManager import DeviceManager
|
|
136
|
-
self.device_manager = DeviceManager(self.config
|
|
137
|
-
self.config.get('windows_capture'),
|
|
138
|
-
self.config.get('adb_capture'),
|
|
139
|
-
self.config.get("debug"),
|
|
139
|
+
self.device_manager = DeviceManager(self.config,
|
|
140
140
|
self.exit_event)
|
|
141
141
|
ok.gui.device_manager = self.device_manager
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import re
|
|
3
|
+
import typing as t
|
|
4
|
+
from dataclasses import dataclass
|
|
5
|
+
|
|
6
|
+
from ok.alas.utils import iter_folder
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def abspath(path):
|
|
10
|
+
return os.path.abspath(path)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def get_serial_pair(serial):
|
|
14
|
+
"""
|
|
15
|
+
Args:
|
|
16
|
+
serial (str):
|
|
17
|
+
|
|
18
|
+
Returns:
|
|
19
|
+
str, str: `127.0.0.1:5555+{X}` and `emulator-5554+{X}`, 0 <= X <= 32
|
|
20
|
+
"""
|
|
21
|
+
if serial.startswith('127.0.0.1:'):
|
|
22
|
+
try:
|
|
23
|
+
port = int(serial[10:])
|
|
24
|
+
if 5555 <= port <= 5555 + 32:
|
|
25
|
+
return f'127.0.0.1:{port}', f'emulator-{port - 1}'
|
|
26
|
+
except (ValueError, IndexError):
|
|
27
|
+
pass
|
|
28
|
+
if serial.startswith('emulator-'):
|
|
29
|
+
try:
|
|
30
|
+
port = int(serial[9:])
|
|
31
|
+
if 5554 <= port <= 5554 + 32:
|
|
32
|
+
return f'127.0.0.1:{port + 1}', f'emulator-{port}'
|
|
33
|
+
except (ValueError, IndexError):
|
|
34
|
+
pass
|
|
35
|
+
|
|
36
|
+
return None, None
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def remove_duplicated_path(paths):
|
|
40
|
+
"""
|
|
41
|
+
Args:
|
|
42
|
+
paths (list[str]):
|
|
43
|
+
|
|
44
|
+
Returns:
|
|
45
|
+
list[str]:
|
|
46
|
+
"""
|
|
47
|
+
paths = sorted(set(paths))
|
|
48
|
+
dic = {}
|
|
49
|
+
for path in paths:
|
|
50
|
+
dic.setdefault(path.lower(), path)
|
|
51
|
+
return list(dic.values())
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
@dataclass
|
|
55
|
+
class EmulatorInstanceBase:
|
|
56
|
+
# Serial for adb connection
|
|
57
|
+
serial: str
|
|
58
|
+
# Emulator instance name, used for start/stop emulator
|
|
59
|
+
name: str
|
|
60
|
+
# Path to emulator .exe
|
|
61
|
+
path: str
|
|
62
|
+
|
|
63
|
+
def __str__(self):
|
|
64
|
+
return f'{self.type}(serial="{self.serial}", name="{self.name}", path="{self.path}")'
|
|
65
|
+
|
|
66
|
+
@property
|
|
67
|
+
def type(self) -> str:
|
|
68
|
+
"""
|
|
69
|
+
Returns:
|
|
70
|
+
str: Emulator type, such as Emulator.NoxPlayer
|
|
71
|
+
"""
|
|
72
|
+
return self.emulator.type
|
|
73
|
+
|
|
74
|
+
@property
|
|
75
|
+
def emulator(self):
|
|
76
|
+
"""
|
|
77
|
+
Returns:
|
|
78
|
+
Emulator:
|
|
79
|
+
"""
|
|
80
|
+
return EmulatorBase(self.path)
|
|
81
|
+
|
|
82
|
+
def __eq__(self, other):
|
|
83
|
+
if isinstance(other, str) and self.type == other:
|
|
84
|
+
return True
|
|
85
|
+
if isinstance(other, list) and self.type in other:
|
|
86
|
+
return True
|
|
87
|
+
if isinstance(other, EmulatorInstanceBase):
|
|
88
|
+
return super().__eq__(other) and self.type == other.type
|
|
89
|
+
return super().__eq__(other)
|
|
90
|
+
|
|
91
|
+
def __hash__(self):
|
|
92
|
+
return hash(str(self))
|
|
93
|
+
|
|
94
|
+
def __bool__(self):
|
|
95
|
+
return True
|
|
96
|
+
|
|
97
|
+
@property
|
|
98
|
+
def MuMuPlayer12_id(self):
|
|
99
|
+
"""
|
|
100
|
+
Convert MuMu 12 instance name to instance id.
|
|
101
|
+
Example names:
|
|
102
|
+
MuMuPlayer-12.0-3
|
|
103
|
+
YXArkNights-12.0-1
|
|
104
|
+
|
|
105
|
+
Returns:
|
|
106
|
+
int: Instance ID, or None if this is not a MuMu 12 instance
|
|
107
|
+
"""
|
|
108
|
+
res = re.search(r'MuMuPlayer(?:Global)?-12.0-(\d+)', self.name)
|
|
109
|
+
if res:
|
|
110
|
+
return int(res.group(1))
|
|
111
|
+
res = re.search(r'YXArkNights-12.0-(\d+)', self.name)
|
|
112
|
+
if res:
|
|
113
|
+
return int(res.group(1))
|
|
114
|
+
|
|
115
|
+
return None
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
class EmulatorBase:
|
|
119
|
+
# Values here must match those in argument.yaml EmulatorInfo.Emulator.option
|
|
120
|
+
NoxPlayer = 'NoxPlayer'
|
|
121
|
+
NoxPlayer64 = 'NoxPlayer64'
|
|
122
|
+
NoxPlayerFamily = [NoxPlayer, NoxPlayer64]
|
|
123
|
+
BlueStacks4 = 'BlueStacks4'
|
|
124
|
+
BlueStacks5 = 'BlueStacks5'
|
|
125
|
+
BlueStacks4HyperV = 'BlueStacks4HyperV'
|
|
126
|
+
BlueStacks5HyperV = 'BlueStacks5HyperV'
|
|
127
|
+
BlueStacksFamily = [BlueStacks4, BlueStacks5]
|
|
128
|
+
LDPlayer3 = 'LDPlayer3'
|
|
129
|
+
LDPlayer4 = 'LDPlayer4'
|
|
130
|
+
LDPlayer9 = 'LDPlayer9'
|
|
131
|
+
LDPlayerFamily = [LDPlayer3, LDPlayer4, LDPlayer9]
|
|
132
|
+
MuMuPlayer = 'MuMuPlayer'
|
|
133
|
+
MuMuPlayerX = 'MuMuPlayerX'
|
|
134
|
+
MuMuPlayer12 = 'MuMuPlayer12'
|
|
135
|
+
MuMuPlayerFamily = [MuMuPlayer, MuMuPlayerX, MuMuPlayer12]
|
|
136
|
+
MEmuPlayer = 'MEmuPlayer'
|
|
137
|
+
|
|
138
|
+
@classmethod
|
|
139
|
+
def path_to_type(cls, path: str) -> str:
|
|
140
|
+
"""
|
|
141
|
+
Args:
|
|
142
|
+
path: Path to .exe file
|
|
143
|
+
|
|
144
|
+
Returns:
|
|
145
|
+
str: Emulator type, such as Emulator.NoxPlayer,
|
|
146
|
+
or '' if this is not a emulator.
|
|
147
|
+
"""
|
|
148
|
+
return ''
|
|
149
|
+
|
|
150
|
+
def iter_instances(self) -> t.Iterable[EmulatorInstanceBase]:
|
|
151
|
+
"""
|
|
152
|
+
Yields:
|
|
153
|
+
EmulatorInstance: Emulator instances found in this emulator
|
|
154
|
+
"""
|
|
155
|
+
pass
|
|
156
|
+
|
|
157
|
+
def iter_adb_binaries(self) -> t.Iterable[str]:
|
|
158
|
+
"""
|
|
159
|
+
Yields:
|
|
160
|
+
str: Filepath to adb binaries found in this emulator
|
|
161
|
+
"""
|
|
162
|
+
pass
|
|
163
|
+
|
|
164
|
+
def __init__(self, path):
|
|
165
|
+
# Path to .exe file
|
|
166
|
+
self.path = path
|
|
167
|
+
# Path to emulator folder
|
|
168
|
+
self.dir = os.path.dirname(path)
|
|
169
|
+
# str: Emulator type, or '' if this is not a emulator.
|
|
170
|
+
self.type = self.__class__.path_to_type(path)
|
|
171
|
+
|
|
172
|
+
def __eq__(self, other):
|
|
173
|
+
if isinstance(other, str) and self.type == other:
|
|
174
|
+
return True
|
|
175
|
+
if isinstance(other, list) and self.type in other:
|
|
176
|
+
return True
|
|
177
|
+
return super().__eq__(other)
|
|
178
|
+
|
|
179
|
+
def __str__(self):
|
|
180
|
+
return f'{self.type}(path="{self.path}")'
|
|
181
|
+
|
|
182
|
+
__repr__ = __str__
|
|
183
|
+
|
|
184
|
+
def __hash__(self):
|
|
185
|
+
return hash(self.path)
|
|
186
|
+
|
|
187
|
+
def __bool__(self):
|
|
188
|
+
return True
|
|
189
|
+
|
|
190
|
+
def abspath(self, path, folder=None):
|
|
191
|
+
if folder is None:
|
|
192
|
+
folder = self.dir
|
|
193
|
+
return abspath(os.path.join(folder, path))
|
|
194
|
+
|
|
195
|
+
@classmethod
|
|
196
|
+
def is_emulator(cls, path: str) -> bool:
|
|
197
|
+
"""
|
|
198
|
+
Args:
|
|
199
|
+
path: Path to .exe file.
|
|
200
|
+
|
|
201
|
+
Returns:
|
|
202
|
+
bool: If this is a emulator.
|
|
203
|
+
"""
|
|
204
|
+
return bool(cls.path_to_type(path))
|
|
205
|
+
|
|
206
|
+
def list_folder(self, folder, is_dir=False, ext=None):
|
|
207
|
+
"""
|
|
208
|
+
Safely list files in a folder
|
|
209
|
+
|
|
210
|
+
Args:
|
|
211
|
+
folder:
|
|
212
|
+
is_dir:
|
|
213
|
+
ext:
|
|
214
|
+
|
|
215
|
+
Returns:
|
|
216
|
+
list[str]:
|
|
217
|
+
"""
|
|
218
|
+
folder = self.abspath(folder)
|
|
219
|
+
return list(iter_folder(folder, is_dir=is_dir, ext=ext))
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
class EmulatorManagerBase:
|
|
223
|
+
@staticmethod
|
|
224
|
+
def iter_running_emulator():
|
|
225
|
+
"""
|
|
226
|
+
Yields:
|
|
227
|
+
str: Path to emulator executables, may contains duplicate values
|
|
228
|
+
"""
|
|
229
|
+
return
|
|
230
|
+
|
|
231
|
+
@property
|
|
232
|
+
def all_emulators(self) -> t.List[EmulatorBase]:
|
|
233
|
+
"""
|
|
234
|
+
Get all emulators installed on current computer.
|
|
235
|
+
"""
|
|
236
|
+
return []
|
|
237
|
+
|
|
238
|
+
@property
|
|
239
|
+
def all_emulator_instances(self) -> t.List[EmulatorInstanceBase]:
|
|
240
|
+
"""
|
|
241
|
+
Get all emulator instances installed on current computer.
|
|
242
|
+
"""
|
|
243
|
+
return []
|
|
244
|
+
|
|
245
|
+
@property
|
|
246
|
+
def all_emulator_serials(self) -> t.List[str]:
|
|
247
|
+
"""
|
|
248
|
+
Returns:
|
|
249
|
+
list[str]: All possible serials on current computer.
|
|
250
|
+
"""
|
|
251
|
+
out = []
|
|
252
|
+
for emulator in self.all_emulator_instances:
|
|
253
|
+
out.append(emulator.serial)
|
|
254
|
+
# Also add serial like `emulator-5554`
|
|
255
|
+
port_serial, emu_serial = get_serial_pair(emulator.serial)
|
|
256
|
+
if emu_serial:
|
|
257
|
+
out.append(emu_serial)
|
|
258
|
+
return out
|
|
259
|
+
|
|
260
|
+
@property
|
|
261
|
+
def all_adb_binaries(self) -> t.List[str]:
|
|
262
|
+
"""
|
|
263
|
+
Returns:
|
|
264
|
+
list[str]: All adb binaries of emulators on current computer.
|
|
265
|
+
"""
|
|
266
|
+
out = []
|
|
267
|
+
for emulator in self.all_emulators:
|
|
268
|
+
for exe in emulator.iter_adb_binaries():
|
|
269
|
+
out.append(exe)
|
|
270
|
+
return out
|