ok-script 0.0.7__tar.gz → 0.0.9__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.7 → ok-script-0.0.9}/PKG-INFO +2 -2
- {ok-script-0.0.7 → ok-script-0.0.9}/README.md +1 -1
- ok-script-0.0.7/autohelper/AutoHelper.py → ok-script-0.0.9/ok/OK.py +23 -19
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/capture/HwndWindow.py +3 -3
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/capture/adb/ADBCaptureMethod.py +2 -2
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/capture/adb/DeviceManager.py +15 -24
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/capture/adb/vbox.py +3 -3
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/capture/windows/WindowsGraphicsCaptureMethod.py +11 -11
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/capture/windows/d3d11.py +2 -2
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/config/Config.py +2 -2
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/config/InfoDict.py +1 -1
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/feature/Box.py +20 -5
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/feature/FeatureSet.py +4 -4
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/feature/FindFeature.py +1 -1
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/gui/App.py +13 -12
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/gui/MainWindow.py +8 -4
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/gui/__init__.py +1 -1
- ok-script-0.0.9/ok/gui/about/AboutTab.py +16 -0
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/gui/debug/DebugTab.py +3 -3
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/gui/debug/FrameWidget.py +2 -2
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/gui/debug/InfoWidget.py +1 -1
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/gui/debug/LoggerWidget.py +1 -1
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/gui/loading/LoadingWindow.py +11 -11
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/gui/overlay/OverlayWindow.py +4 -4
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/gui/tasks/ConfigItemFactory.py +3 -3
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/gui/tasks/StartButton.py +6 -6
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/gui/tasks/TaskOpButton.py +2 -2
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/gui/tasks/TaskTab.py +9 -9
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/gui/util/Alert.py +2 -2
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/gui/util/InitWorker.py +2 -2
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/gui/widget/ListTableWidgetItem.py +1 -1
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/gui/widget/NumericTableWidgetItem.py +1 -1
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/gui/widget/YesNonWidgetItem.py +1 -1
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/interaction/ADBInteraction.py +2 -2
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/interaction/BaseInteraction.py +3 -3
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/interaction/Win32Interaction.py +3 -3
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/logging/Logger.py +3 -3
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/ocr/OCR.py +3 -3
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/rotypes/Windows/Foundation/Collections.py +2 -2
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/rotypes/Windows/Foundation/__init__.py +3 -3
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/rotypes/Windows/Globalization/__init__.py +3 -3
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/rotypes/Windows/Graphics/Capture/__init__.py +7 -7
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/rotypes/Windows/Graphics/DirectX/Direct3D11/__init__.py +4 -4
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/rotypes/Windows/Graphics/DirectX/__init__.py +1 -1
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/rotypes/Windows/Graphics/Imaging/__init__.py +5 -5
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/rotypes/Windows/Media/Ocr/__init__.py +7 -7
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/rotypes/Windows/Security/Cryptography/__init__.py +2 -2
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/rotypes/Windows/Storage/Streams/__init__.py +2 -2
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/save/BlackBarProcessor.py +1 -1
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/save/SaveByInterval.py +1 -1
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/save/SaveByKeyPress.py +3 -3
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/save/SaveMethodBase.py +2 -2
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/scene/FeatureScene.py +2 -2
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/scene/Scene.py +3 -3
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/task/BaseTask.py +10 -7
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/task/ExecutorOperation.py +8 -8
- ok-script-0.0.9/ok/task/FindFeatureTask.py +6 -0
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/task/TaskExecutor.py +6 -11
- ok-script-0.0.9/ok/util/__init__.py +0 -0
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/util/json.py +1 -1
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/util/yaml.py +1 -1
- {ok-script-0.0.7 → ok-script-0.0.9}/ok_script.egg-info/PKG-INFO +2 -2
- ok-script-0.0.9/ok_script.egg-info/SOURCES.txt +127 -0
- ok-script-0.0.9/ok_script.egg-info/top_level.txt +1 -0
- {ok-script-0.0.7 → ok-script-0.0.9}/setup.py +1 -1
- ok-script-0.0.7/autohelper/task/FindFeatureTask.py +0 -6
- ok-script-0.0.7/ok_script.egg-info/SOURCES.txt +0 -125
- ok-script-0.0.7/ok_script.egg-info/top_level.txt +0 -1
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/__init__.py +0 -0
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/capture/BaseCaptureMethod.py +0 -0
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/capture/__init__.py +0 -0
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/capture/adb/__init__.py +0 -0
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/capture/adb/bin/__init__.py +0 -0
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/capture/adb/targets.py +0 -0
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/capture/windows/__init__.py +0 -0
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/capture/windows/utils.py +0 -0
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/capture/windows/window.py +0 -0
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/color/Color.py +0 -0
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/color/__init__.py +0 -0
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/config/__init__.py +0 -0
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/feature/Feature.py +0 -0
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/feature/__init__.py +0 -0
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/gui/Communicate.py +0 -0
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/gui/TabTitles.py +0 -0
- {ok-script-0.0.7/autohelper/gui/debug → ok-script-0.0.9/ok/gui/about}/__init__.py +0 -0
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/gui/debug/AspectRatioWidget.py +0 -0
- {ok-script-0.0.7/autohelper/gui/i18n → ok-script-0.0.9/ok/gui/debug}/__init__.py +0 -0
- {ok-script-0.0.7/autohelper/gui/icon → ok-script-0.0.9/ok/gui/i18n}/__init__.py +0 -0
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/gui/i18n/path.py +0 -0
- {ok-script-0.0.7/autohelper/gui/loading → ok-script-0.0.9/ok/gui/icon}/__init__.py +0 -0
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/gui/icon/icon.py +0 -0
- {ok-script-0.0.7/autohelper/gui/overlay → ok-script-0.0.9/ok/gui/loading}/__init__.py +0 -0
- {ok-script-0.0.7/autohelper/gui/tasks → ok-script-0.0.9/ok/gui/overlay}/__init__.py +0 -0
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/gui/resources.py +0 -0
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/gui/tasks/TooltipTableWidget.py +0 -0
- {ok-script-0.0.7/autohelper/gui/util → ok-script-0.0.9/ok/gui/tasks}/__init__.py +0 -0
- {ok-script-0.0.7/autohelper/gui/widget → ok-script-0.0.9/ok/gui/util}/__init__.py +0 -0
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/gui/widget/RoundCornerContainer.py +0 -0
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/gui/widget/TabWidget.py +0 -0
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/gui/widget/UpdateConfigWidgetItem.py +0 -0
- {ok-script-0.0.7/autohelper/interaction → ok-script-0.0.9/ok/gui/widget}/__init__.py +0 -0
- {ok-script-0.0.7/autohelper/logging → ok-script-0.0.9/ok/interaction}/__init__.py +0 -0
- {ok-script-0.0.7/autohelper/ocr → ok-script-0.0.9/ok/logging}/__init__.py +0 -0
- {ok-script-0.0.7/autohelper/predict → ok-script-0.0.9/ok/ocr}/__init__.py +0 -0
- {ok-script-0.0.7/autohelper/rotypes/Windows/Media → ok-script-0.0.9/ok/predict}/__init__.py +0 -0
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/predict/predict.py +0 -0
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/rotypes/Windows/Graphics/__init__.py +0 -0
- {ok-script-0.0.7/autohelper/rotypes/Windows/Security → ok-script-0.0.9/ok/rotypes/Windows/Media}/__init__.py +0 -0
- {ok-script-0.0.7/autohelper/rotypes/Windows/Storage → ok-script-0.0.9/ok/rotypes/Windows/Security}/__init__.py +0 -0
- {ok-script-0.0.7/autohelper/rotypes/Windows → ok-script-0.0.9/ok/rotypes/Windows/Storage}/__init__.py +0 -0
- {ok-script-0.0.7/autohelper/save → ok-script-0.0.9/ok/rotypes/Windows}/__init__.py +0 -0
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/rotypes/__init__.py +0 -0
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/rotypes/delegate.py +0 -0
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/rotypes/export.py +0 -0
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/rotypes/idldsl.py +0 -0
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/rotypes/inspectable.py +0 -0
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/rotypes/roapi.py +0 -0
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/rotypes/types.py +0 -0
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/rotypes/winstring.py +0 -0
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/save/PostProcessor.py +0 -0
- {ok-script-0.0.7/autohelper/scene → ok-script-0.0.9/ok/save}/__init__.py +0 -0
- {ok-script-0.0.7/autohelper/stats → ok-script-0.0.9/ok/scene}/__init__.py +0 -0
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/stats/StreamStats.py +0 -0
- {ok-script-0.0.7/autohelper/task → ok-script-0.0.9/ok/stats}/__init__.py +0 -0
- {ok-script-0.0.7/autohelper/util → ok-script-0.0.9/ok/task}/__init__.py +0 -0
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/util/list.py +0 -0
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/util/path.py +0 -0
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/util/thread.py +0 -0
- {ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/util/win32_process.py +0 -0
- {ok-script-0.0.7 → ok-script-0.0.9}/ok_script.egg-info/dependency_links.txt +0 -0
- {ok-script-0.0.7 → ok-script-0.0.9}/ok_script.egg-info/requires.txt +0 -0
- {ok-script-0.0.7 → ok-script-0.0.9}/setup.cfg +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.9
|
|
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
|
|
@@ -18,7 +18,7 @@ Requires-Dist: pywin32==306
|
|
|
18
18
|
Requires-Dist: typing-extensions~=4.10.0
|
|
19
19
|
Requires-Dist: PySide6~=6.6.2
|
|
20
20
|
|
|
21
|
-
#
|
|
21
|
+
# ok-script
|
|
22
22
|
|
|
23
23
|
This project aims to provide a universal framework for developing automation tool for PC/Android games, running in
|
|
24
24
|
windows,
|
|
@@ -5,19 +5,19 @@ from typing import Dict, Any
|
|
|
5
5
|
|
|
6
6
|
from PySide6.QtWidgets import QApplication
|
|
7
7
|
|
|
8
|
-
import
|
|
9
|
-
from
|
|
10
|
-
from
|
|
11
|
-
from
|
|
12
|
-
from
|
|
13
|
-
from
|
|
14
|
-
from
|
|
15
|
-
from
|
|
8
|
+
import ok
|
|
9
|
+
from ok.feature.FeatureSet import FeatureSet
|
|
10
|
+
from ok.gui.App import App
|
|
11
|
+
from ok.gui.Communicate import communicate
|
|
12
|
+
from ok.gui.overlay.OverlayWindow import OverlayWindow
|
|
13
|
+
from ok.gui.util.InitWorker import InitWorker
|
|
14
|
+
from ok.logging.Logger import get_logger, config_logger
|
|
15
|
+
from ok.task.TaskExecutor import TaskExecutor
|
|
16
16
|
|
|
17
17
|
logger = get_logger(__name__)
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
class
|
|
20
|
+
class OK:
|
|
21
21
|
executor: TaskExecutor
|
|
22
22
|
adb = None
|
|
23
23
|
adb_device = None
|
|
@@ -36,20 +36,24 @@ class AutoHelper:
|
|
|
36
36
|
self.init_device_manager()
|
|
37
37
|
if config.get("use_gui"):
|
|
38
38
|
self.app = App(self.config.get('gui_icon'), self.debug, self.config.get('gui_title'),
|
|
39
|
-
self.config['tasks'], self.exit_event)
|
|
40
|
-
|
|
39
|
+
self.config['tasks'], self.config.get('about'), self.exit_event)
|
|
40
|
+
ok.gui.app = self.app
|
|
41
|
+
else:
|
|
42
|
+
self.device_manager.set_preferred_device()
|
|
43
|
+
self.device_manager.start()
|
|
44
|
+
self.do_init()
|
|
45
|
+
|
|
46
|
+
def start(self):
|
|
47
|
+
if self.config.get("use_gui"):
|
|
41
48
|
self.app.show_loading()
|
|
42
49
|
self.worker = InitWorker(self.do_init)
|
|
43
50
|
self.worker.start()
|
|
44
51
|
self.app.exec()
|
|
45
52
|
else:
|
|
46
|
-
self.device_manager.set_preferred_device()
|
|
47
|
-
self.device_manager.start()
|
|
48
|
-
self.do_init()
|
|
49
53
|
self.task_executor.start()
|
|
50
|
-
if config.get("debug"):
|
|
54
|
+
if self.config.get("debug"):
|
|
51
55
|
self.app = QApplication(sys.argv)
|
|
52
|
-
self.overlay_window = OverlayWindow(
|
|
56
|
+
self.overlay_window = OverlayWindow(ok.gui.device_manager.hwnd)
|
|
53
57
|
self.app.exec()
|
|
54
58
|
else:
|
|
55
59
|
try:
|
|
@@ -101,7 +105,7 @@ class AutoHelper:
|
|
|
101
105
|
self.init_message("TaskExecutor init Done")
|
|
102
106
|
|
|
103
107
|
if self.app:
|
|
104
|
-
|
|
108
|
+
ok.gui.executor = self.task_executor
|
|
105
109
|
|
|
106
110
|
def wait_task(self):
|
|
107
111
|
while not self.exit_event.is_set():
|
|
@@ -109,8 +113,8 @@ class AutoHelper:
|
|
|
109
113
|
|
|
110
114
|
def init_device_manager(self):
|
|
111
115
|
if self.device_manager is None:
|
|
112
|
-
from
|
|
116
|
+
from ok.capture.adb.DeviceManager import DeviceManager
|
|
113
117
|
self.device_manager = DeviceManager(self.config.get("config_folder") or "config",
|
|
114
118
|
self.config.get('capture_window_title'), self.config.get("debug"),
|
|
115
119
|
self.exit_event)
|
|
116
|
-
|
|
120
|
+
ok.gui.device_manager = self.device_manager
|
|
@@ -5,9 +5,9 @@ import threading
|
|
|
5
5
|
from typing_extensions import override
|
|
6
6
|
from win32 import win32gui
|
|
7
7
|
|
|
8
|
-
from
|
|
9
|
-
from
|
|
10
|
-
from
|
|
8
|
+
from ok.capture.windows.window import is_foreground_window, get_window_bounds
|
|
9
|
+
from ok.gui.Communicate import communicate
|
|
10
|
+
from ok.logging.Logger import get_logger
|
|
11
11
|
|
|
12
12
|
logger = get_logger(__name__)
|
|
13
13
|
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import numpy as np
|
|
3
3
|
from typing_extensions import override
|
|
4
4
|
|
|
5
|
-
from
|
|
6
|
-
from
|
|
5
|
+
from ok.capture.BaseCaptureMethod import BaseCaptureMethod
|
|
6
|
+
from ok.logging.Logger import get_logger
|
|
7
7
|
|
|
8
8
|
logger = get_logger(__name__)
|
|
9
9
|
|
|
@@ -4,15 +4,15 @@ import adbutils
|
|
|
4
4
|
import cv2
|
|
5
5
|
import numpy as np
|
|
6
6
|
|
|
7
|
-
from
|
|
8
|
-
from
|
|
9
|
-
from
|
|
10
|
-
from
|
|
11
|
-
from
|
|
12
|
-
from
|
|
13
|
-
from
|
|
14
|
-
from
|
|
15
|
-
from
|
|
7
|
+
from ok.capture.HwndWindow import HwndWindow
|
|
8
|
+
from ok.capture.adb.ADBCaptureMethod import ADBCaptureMethod
|
|
9
|
+
from ok.capture.adb.vbox import installed_emulator
|
|
10
|
+
from ok.capture.windows.WindowsGraphicsCaptureMethod import WindowsGraphicsCaptureMethod
|
|
11
|
+
from ok.config.Config import Config
|
|
12
|
+
from ok.gui.Communicate import communicate
|
|
13
|
+
from ok.interaction.ADBInteraction import ADBBaseInteraction
|
|
14
|
+
from ok.interaction.Win32Interaction import Win32Interaction
|
|
15
|
+
from ok.logging.Logger import get_logger
|
|
16
16
|
|
|
17
17
|
logger = get_logger(__name__)
|
|
18
18
|
|
|
@@ -102,7 +102,6 @@ class DeviceManager:
|
|
|
102
102
|
self.device_dict[self.hwnd_title] = {"address": "", "imei": self.hwnd_title, "method": "windows",
|
|
103
103
|
"model": "", "nick": nick or self.hwnd_title,
|
|
104
104
|
"connected": self.hwnd is not None and self.hwnd.exists,
|
|
105
|
-
"preferred": False,
|
|
106
105
|
"resolution": f"{width}x{height}"}
|
|
107
106
|
communicate.adb_devices.emit()
|
|
108
107
|
self.config.save_file()
|
|
@@ -110,20 +109,13 @@ class DeviceManager:
|
|
|
110
109
|
|
|
111
110
|
def set_preferred_device(self, imei=None):
|
|
112
111
|
logger.debug(f"set_preferred_device {imei}")
|
|
113
|
-
preferred = None
|
|
114
112
|
if imei is None:
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
preferred = device
|
|
118
|
-
imei = preferred['imei']
|
|
119
|
-
else:
|
|
120
|
-
preferred = self.device_dict.get(imei)
|
|
121
|
-
for key in self.device_dict.keys():
|
|
122
|
-
if imei == key:
|
|
123
|
-
self.device_dict[imei]["preferred"] = False
|
|
113
|
+
imei = self.config.get("preferred")
|
|
114
|
+
preferred = self.device_dict.get(imei)
|
|
124
115
|
if preferred is None and len(self.device_dict) > 0:
|
|
125
116
|
preferred = next(iter(self.device_dict.values()))
|
|
126
117
|
if preferred is not None:
|
|
118
|
+
imei = preferred['imei']
|
|
127
119
|
preferred['preferred'] = True
|
|
128
120
|
if preferred['method'] == 'windows':
|
|
129
121
|
if not isinstance(self.capture_method, WindowsGraphicsCaptureMethod):
|
|
@@ -141,6 +133,7 @@ class DeviceManager:
|
|
|
141
133
|
self.capture_method.close()
|
|
142
134
|
self.capture_method = ADBCaptureMethod(self)
|
|
143
135
|
self.interaction = ADBBaseInteraction(self, self.capture_method)
|
|
136
|
+
self.config["preferred"] = imei
|
|
144
137
|
self.config.save_file()
|
|
145
138
|
logger.debug(f'preferred device: {preferred}')
|
|
146
139
|
|
|
@@ -148,10 +141,10 @@ class DeviceManager:
|
|
|
148
141
|
if isinstance(self.capture_method, ADBCaptureMethod):
|
|
149
142
|
if self.debug:
|
|
150
143
|
if self.hwnd is not None:
|
|
151
|
-
self.hwnd.update_title_re("
|
|
144
|
+
self.hwnd.update_title_re("ok_debug")
|
|
152
145
|
self.hwnd.update_frame_size(self.capture_method.width, self.capture_method.height)
|
|
153
146
|
else:
|
|
154
|
-
self.hwnd = HwndWindow("
|
|
147
|
+
self.hwnd = HwndWindow("ok_debug", self.exit_event, self.capture_method.width,
|
|
155
148
|
self.capture_method.height)
|
|
156
149
|
else:
|
|
157
150
|
self.hwnd.stop()
|
|
@@ -159,8 +152,6 @@ class DeviceManager:
|
|
|
159
152
|
|
|
160
153
|
@property
|
|
161
154
|
def device(self):
|
|
162
|
-
if self._device is None:
|
|
163
|
-
self.set_preferred_device()
|
|
164
155
|
return self._device
|
|
165
156
|
|
|
166
157
|
@property
|
|
@@ -6,9 +6,9 @@ from dataclasses import dataclass
|
|
|
6
6
|
import adbutils
|
|
7
7
|
import win32com.client
|
|
8
8
|
|
|
9
|
-
from
|
|
10
|
-
from
|
|
11
|
-
from
|
|
9
|
+
from ok.capture.adb.targets import ADBControllerTarget
|
|
10
|
+
from ok.logging.Logger import get_logger
|
|
11
|
+
from ok.util import win32_process
|
|
12
12
|
|
|
13
13
|
logger = get_logger(__name__)
|
|
14
14
|
|
{ok-script-0.0.7/autohelper → ok-script-0.0.9/ok}/capture/windows/WindowsGraphicsCaptureMethod.py
RENAMED
|
@@ -6,20 +6,20 @@ import time
|
|
|
6
6
|
import numpy as np
|
|
7
7
|
from typing_extensions import override
|
|
8
8
|
|
|
9
|
-
from
|
|
10
|
-
from
|
|
11
|
-
from
|
|
12
|
-
from
|
|
13
|
-
from
|
|
14
|
-
from
|
|
15
|
-
from
|
|
16
|
-
from
|
|
9
|
+
from ok.capture.BaseCaptureMethod import BaseCaptureMethod
|
|
10
|
+
from ok.capture.HwndWindow import HwndWindow
|
|
11
|
+
from ok.capture.windows import d3d11
|
|
12
|
+
from ok.capture.windows.utils import WINDOWS_BUILD_NUMBER
|
|
13
|
+
from ok.logging.Logger import get_logger
|
|
14
|
+
from ok.rotypes import IInspectable
|
|
15
|
+
from ok.rotypes.Windows.Foundation import TypedEventHandler
|
|
16
|
+
from ok.rotypes.Windows.Graphics.Capture import Direct3D11CaptureFramePool, IGraphicsCaptureItemInterop, \
|
|
17
17
|
IGraphicsCaptureItem, GraphicsCaptureItem
|
|
18
|
-
from
|
|
19
|
-
from
|
|
18
|
+
from ok.rotypes.Windows.Graphics.DirectX import DirectXPixelFormat
|
|
19
|
+
from ok.rotypes.Windows.Graphics.DirectX.Direct3D11 import IDirect3DDevice, \
|
|
20
20
|
CreateDirect3D11DeviceFromDXGIDevice, \
|
|
21
21
|
IDirect3DDxgiInterfaceAccess
|
|
22
|
-
from
|
|
22
|
+
from ok.rotypes.roapi import GetActivationFactory
|
|
23
23
|
|
|
24
24
|
PBYTE = ctypes.POINTER(ctypes.c_ubyte)
|
|
25
25
|
WGC_NO_BORDER_MIN_BUILD = 20348
|
|
@@ -24,6 +24,14 @@ class Box:
|
|
|
24
24
|
self.confidence == other.confidence and
|
|
25
25
|
self.name == other.name)
|
|
26
26
|
|
|
27
|
+
def in_boundary(self, boxes):
|
|
28
|
+
in_boundary_boxes = []
|
|
29
|
+
for box in boxes:
|
|
30
|
+
if (self.x <= box.x and self.x + self.width >= box.x + box.width and
|
|
31
|
+
self.y <= box.y and self.y + self.height >= box.y + box.height):
|
|
32
|
+
in_boundary_boxes.append(box)
|
|
33
|
+
return in_boundary_boxes
|
|
34
|
+
|
|
27
35
|
def __repr__(self):
|
|
28
36
|
return self.name
|
|
29
37
|
|
|
@@ -80,7 +88,7 @@ class Box:
|
|
|
80
88
|
def center(self):
|
|
81
89
|
return self.x + self.width / 2, self.y + self.height / 2
|
|
82
90
|
|
|
83
|
-
def find_closest_box(self, direction: str, boxes: list):
|
|
91
|
+
def find_closest_box(self, direction: str, boxes: list, condition=None):
|
|
84
92
|
orig_center_x, orig_center_y = self.center()
|
|
85
93
|
|
|
86
94
|
def distance_criteria(box):
|
|
@@ -91,14 +99,21 @@ class Box:
|
|
|
91
99
|
dy = box_center_y - orig_center_y
|
|
92
100
|
distance = math.sqrt(dx ** 2 + dy ** 2)
|
|
93
101
|
if box == self:
|
|
94
|
-
|
|
102
|
+
distance = float('inf')
|
|
95
103
|
elif direction == 'up' and self.y - (box.y + box.height / 2) >= 0:
|
|
96
|
-
|
|
104
|
+
pass
|
|
97
105
|
elif direction == 'down' and box.y - (self.y + self.height / 2) >= 0:
|
|
98
|
-
|
|
106
|
+
pass
|
|
99
107
|
elif direction == 'left' and self.x - (box.x + box.width / 2) >= 0:
|
|
100
|
-
|
|
108
|
+
pass
|
|
101
109
|
elif direction == 'right' and box.x - (self.x + self.width / 2) >= 0:
|
|
110
|
+
pass
|
|
111
|
+
else:
|
|
112
|
+
distance = float('inf')
|
|
113
|
+
return check_condition(box, distance)
|
|
114
|
+
|
|
115
|
+
def check_condition(box, distance):
|
|
116
|
+
if condition is None or condition(box):
|
|
102
117
|
return distance
|
|
103
118
|
else:
|
|
104
119
|
return float('inf')
|
|
@@ -7,10 +7,10 @@ from typing import List
|
|
|
7
7
|
import cv2
|
|
8
8
|
import numpy as np
|
|
9
9
|
|
|
10
|
-
from
|
|
11
|
-
from
|
|
12
|
-
from
|
|
13
|
-
from
|
|
10
|
+
from ok.feature.Box import Box, sort_boxes
|
|
11
|
+
from ok.feature.Feature import Feature
|
|
12
|
+
from ok.gui.Communicate import communicate
|
|
13
|
+
from ok.logging.Logger import get_logger
|
|
14
14
|
|
|
15
15
|
logger = get_logger(__name__)
|
|
16
16
|
|
|
@@ -5,25 +5,26 @@ from PySide6.QtCore import QSize, QCoreApplication, QLocale, QTranslator
|
|
|
5
5
|
from PySide6.QtGui import QIcon
|
|
6
6
|
from PySide6.QtWidgets import QApplication, QStyleFactory, QMenu, QSystemTrayIcon
|
|
7
7
|
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
from
|
|
11
|
-
from
|
|
12
|
-
from
|
|
13
|
-
from
|
|
14
|
-
from
|
|
15
|
-
from
|
|
8
|
+
import ok
|
|
9
|
+
import ok.gui.resources
|
|
10
|
+
from ok.gui.Communicate import communicate
|
|
11
|
+
from ok.gui.MainWindow import MainWindow
|
|
12
|
+
from ok.gui.i18n.path import i18n_path
|
|
13
|
+
from ok.gui.loading.LoadingWindow import LoadingWindow
|
|
14
|
+
from ok.gui.overlay.OverlayWindow import OverlayWindow
|
|
15
|
+
from ok.logging.Logger import get_logger
|
|
16
16
|
|
|
17
17
|
logger = get_logger(__name__)
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
class App:
|
|
21
|
-
def __init__(self, icon=None, overlay=False, title="AutoUI", tasks=None,
|
|
21
|
+
def __init__(self, icon=None, overlay=False, title="AutoUI", tasks=None, about=None,
|
|
22
22
|
exit_event=None):
|
|
23
23
|
super().__init__()
|
|
24
24
|
self.app = QApplication(sys.argv)
|
|
25
25
|
self.app.setStyle(QStyleFactory.create("Fusion"))
|
|
26
26
|
self.tasks = tasks
|
|
27
|
+
self.about = about
|
|
27
28
|
self.title = title
|
|
28
29
|
self.overlay = overlay
|
|
29
30
|
self.loading_window = None
|
|
@@ -86,11 +87,11 @@ class App:
|
|
|
86
87
|
|
|
87
88
|
def show_main_window(self):
|
|
88
89
|
self.loading_window.close()
|
|
89
|
-
self.main_window = MainWindow(self.tasks, self.overlay, exit_event=self.exit_event)
|
|
90
|
+
self.main_window = MainWindow(self.tasks, self.overlay, self.about, exit_event=self.exit_event)
|
|
90
91
|
self.main_window.setWindowTitle(self.title) # Set the window title here
|
|
91
92
|
self.main_window.setWindowIcon(self.icon)
|
|
92
|
-
if self.overlay and
|
|
93
|
-
self.overlay_window = OverlayWindow(
|
|
93
|
+
if self.overlay and ok.gui.device_manager.hwnd is not None:
|
|
94
|
+
self.overlay_window = OverlayWindow(ok.gui.device_manager.hwnd)
|
|
94
95
|
|
|
95
96
|
size = self.size_relative_to_screen(width=0.5, height=0.6)
|
|
96
97
|
self.main_window.resize(size)
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
from PySide6.QtCore import QObject, Signal, Slot
|
|
2
2
|
from PySide6.QtWidgets import QMessageBox, QTabWidget
|
|
3
3
|
|
|
4
|
-
from
|
|
5
|
-
from
|
|
6
|
-
from
|
|
4
|
+
from ok.gui.about.AboutTab import AboutTab
|
|
5
|
+
from ok.gui.debug.DebugTab import DebugTab
|
|
6
|
+
from ok.gui.tasks.TaskTab import TaskTab
|
|
7
|
+
from ok.logging.Logger import get_logger
|
|
7
8
|
|
|
8
9
|
logger = get_logger(__name__)
|
|
9
10
|
|
|
@@ -13,7 +14,7 @@ class Communicate(QObject):
|
|
|
13
14
|
|
|
14
15
|
|
|
15
16
|
class MainWindow(QTabWidget):
|
|
16
|
-
def __init__(self, tasks, debug=False, exit_event=None):
|
|
17
|
+
def __init__(self, tasks, debug=False, about=None, exit_event=None):
|
|
17
18
|
super().__init__()
|
|
18
19
|
self.exit_event = exit_event
|
|
19
20
|
task_tab = TaskTab(tasks)
|
|
@@ -22,6 +23,9 @@ class MainWindow(QTabWidget):
|
|
|
22
23
|
debug_tab = DebugTab()
|
|
23
24
|
self.addTab(debug_tab, self.tr("Debug"))
|
|
24
25
|
# ... Add other tabs similarly
|
|
26
|
+
if about:
|
|
27
|
+
about_tab = AboutTab(about)
|
|
28
|
+
self.addTab(about_tab, self.tr("About"))
|
|
25
29
|
|
|
26
30
|
# Styling the tabs and content if needed, for example:
|
|
27
31
|
self.setStyleSheet("""
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
from PySide6.QtWidgets import QWidget, QTextEdit, QVBoxLayout
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class AboutTab(QWidget):
|
|
5
|
+
def __init__(self, text=""):
|
|
6
|
+
super().__init__()
|
|
7
|
+
layout = QVBoxLayout()
|
|
8
|
+
|
|
9
|
+
# Create a QTextEdit instance
|
|
10
|
+
text_edit = QTextEdit()
|
|
11
|
+
text_edit.setHtml(text)
|
|
12
|
+
text_edit.setReadOnly(True)
|
|
13
|
+
layout.addWidget(text_edit)
|
|
14
|
+
|
|
15
|
+
# Set the layout on the widget
|
|
16
|
+
self.setLayout(layout)
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
from PySide6.QtCore import Qt
|
|
2
2
|
from PySide6.QtWidgets import QWidget, QGridLayout, QSplitter
|
|
3
3
|
|
|
4
|
-
from
|
|
5
|
-
from
|
|
6
|
-
from
|
|
4
|
+
from ok.gui.debug.FrameWidget import FrameWidget
|
|
5
|
+
from ok.gui.debug.InfoWidget import InfoWidget
|
|
6
|
+
from ok.gui.debug.LoggerWidget import LoggerWidget
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
class DebugTab(QWidget):
|
|
@@ -5,8 +5,8 @@ from PySide6.QtCore import Qt
|
|
|
5
5
|
from PySide6.QtGui import QPainter, QImage, QPixmap, QColor, QPen
|
|
6
6
|
from PySide6.QtWidgets import QWidget
|
|
7
7
|
|
|
8
|
-
from
|
|
9
|
-
from
|
|
8
|
+
from ok.feature.Box import Box
|
|
9
|
+
from ok.gui.Communicate import communicate
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
class FrameWidget(QWidget):
|
|
@@ -2,7 +2,7 @@ import logging
|
|
|
2
2
|
|
|
3
3
|
from PySide6.QtWidgets import (QWidget, QVBoxLayout, QHBoxLayout, QComboBox, QLineEdit, QTextEdit)
|
|
4
4
|
|
|
5
|
-
from
|
|
5
|
+
from ok.gui.Communicate import communicate
|
|
6
6
|
|
|
7
7
|
level_map = {'DEBUG': logging.DEBUG, 'INFO': logging.INFO, 'WARNING': logging.WARNING, 'ERROR': logging.ERROR,
|
|
8
8
|
'CRITICAL': logging.CRITICAL}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
from PySide6.QtCore import Qt, QTimer
|
|
2
2
|
from PySide6.QtWidgets import QWidget, QVBoxLayout, QMessageBox, QHBoxLayout, QListWidget, QPushButton
|
|
3
3
|
|
|
4
|
-
import
|
|
5
|
-
from
|
|
6
|
-
from
|
|
7
|
-
from
|
|
8
|
-
from
|
|
9
|
-
from
|
|
4
|
+
import ok
|
|
5
|
+
from ok.gui.Communicate import communicate
|
|
6
|
+
from ok.gui.util.Alert import show_alert
|
|
7
|
+
from ok.gui.widget.RoundCornerContainer import RoundCornerContainer
|
|
8
|
+
from ok.interaction.Win32Interaction import is_admin
|
|
9
|
+
from ok.logging.Logger import get_logger
|
|
10
10
|
|
|
11
11
|
logger = get_logger(__name__)
|
|
12
12
|
|
|
@@ -50,7 +50,7 @@ class LoadingWindow(QWidget):
|
|
|
50
50
|
self.update_capture()
|
|
51
51
|
|
|
52
52
|
def refresh_clicked(self):
|
|
53
|
-
|
|
53
|
+
ok.gui.device_manager.refresh()
|
|
54
54
|
self.refresh_button.setDisabled(True)
|
|
55
55
|
self.refresh_button.setText(self.tr("Refreshing"))
|
|
56
56
|
|
|
@@ -65,22 +65,22 @@ class LoadingWindow(QWidget):
|
|
|
65
65
|
show_alert(self.tr("Error"),
|
|
66
66
|
self.tr(f"PC version requires admin privileges, Please restart this app with admin privileges!"))
|
|
67
67
|
return
|
|
68
|
-
|
|
68
|
+
ok.gui.device_manager.start()
|
|
69
69
|
self.app.show_main_window()
|
|
70
70
|
|
|
71
71
|
def capture_index_changed(self): # i is an index
|
|
72
72
|
i = self.capture_list.currentRow()
|
|
73
73
|
imei = self.capture_list_data[i]["imei"]
|
|
74
|
-
|
|
74
|
+
ok.gui.device_manager.set_preferred_device(imei)
|
|
75
75
|
|
|
76
76
|
def update_capture(self):
|
|
77
|
-
devices =
|
|
77
|
+
devices = ok.gui.device_manager.get_devices()
|
|
78
78
|
selected = self.capture_list.currentRow()
|
|
79
79
|
self.capture_list.clear()
|
|
80
80
|
self.capture_list_data.clear()
|
|
81
81
|
if len(devices) > 0:
|
|
82
82
|
for row, device in enumerate(devices):
|
|
83
|
-
if device["preferred"
|
|
83
|
+
if device["imei"] == ok.gui.device_manager.config.get("preferred"):
|
|
84
84
|
selected = row
|
|
85
85
|
method = self.tr("PC") if device['method'] == "windows" else self.tr("Android")
|
|
86
86
|
connected = self.tr("Connected") if device['connected'] else self.tr("Disconnected")
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
from PySide6.QtCore import QObject, Signal, Qt
|
|
2
2
|
|
|
3
|
-
from
|
|
4
|
-
from
|
|
5
|
-
from
|
|
6
|
-
from
|
|
3
|
+
from ok.capture.HwndWindow import HwndWindow
|
|
4
|
+
from ok.gui.Communicate import communicate
|
|
5
|
+
from ok.gui.debug.FrameWidget import FrameWidget
|
|
6
|
+
from ok.logging.Logger import get_logger
|
|
7
7
|
|
|
8
8
|
logger = get_logger(__name__)
|
|
9
9
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
from
|
|
2
|
-
from
|
|
3
|
-
from
|
|
1
|
+
from ok.gui.widget.ListTableWidgetItem import ListTableWidgetItem
|
|
2
|
+
from ok.gui.widget.NumericTableWidgetItem import NumericTableWidgetItem
|
|
3
|
+
from ok.gui.widget.YesNonWidgetItem import YesNonWidgetItem
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
def config_widget_item(table, row, col, config, key, value):
|
|
@@ -2,10 +2,10 @@ from PySide6.QtCore import Slot, QPropertyAnimation
|
|
|
2
2
|
from PySide6.QtGui import QColor
|
|
3
3
|
from PySide6.QtWidgets import QPushButton
|
|
4
4
|
|
|
5
|
-
import
|
|
6
|
-
from
|
|
7
|
-
from
|
|
8
|
-
from
|
|
5
|
+
import ok
|
|
6
|
+
from ok.gui.Communicate import communicate
|
|
7
|
+
from ok.gui.util.Alert import show_alert
|
|
8
|
+
from ok.logging.Logger import get_logger
|
|
9
9
|
|
|
10
10
|
logger = get_logger(__name__)
|
|
11
11
|
|
|
@@ -33,12 +33,12 @@ class StartButton(QPushButton):
|
|
|
33
33
|
def toggle_text(self):
|
|
34
34
|
if self.isChecked():
|
|
35
35
|
logger.info("Click Start Executor")
|
|
36
|
-
if not
|
|
36
|
+
if not ok.gui.executor.start():
|
|
37
37
|
show_alert("Error", "No Task to Run, Please Enable Task First!")
|
|
38
38
|
self.setChecked(False)
|
|
39
39
|
else:
|
|
40
40
|
logger.info("Click Pause Executor")
|
|
41
|
-
|
|
41
|
+
ok.gui.executor.pause()
|
|
42
42
|
|
|
43
43
|
def start_animation(self):
|
|
44
44
|
self.animation.setStartValue(QColor(0, 0, 0))
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
from PySide6.QtCore import Slot
|
|
2
2
|
from PySide6.QtWidgets import QPushButton
|
|
3
3
|
|
|
4
|
-
from
|
|
5
|
-
from
|
|
4
|
+
from ok.logging.Logger import get_logger
|
|
5
|
+
from ok.task.BaseTask import BaseTask
|
|
6
6
|
|
|
7
7
|
logger = get_logger(__name__)
|
|
8
8
|
|