ok-script 0.0.34__tar.gz → 0.0.35__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.34 → ok-script-0.0.35}/PKG-INFO +1 -1
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/capture/BaseCaptureMethod.py +8 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/capture/adb/ADBCaptureMethod.py +1 -1
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/capture/windows/WindowsGraphicsCaptureMethod.py +1 -1
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/gui/App.py +2 -33
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/gui/Communicate.py +2 -1
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/gui/MainWindow.py +37 -1
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/gui/tasks/OneTimeTaskTab.py +1 -2
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/logging/Logger.py +11 -1
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/task/BaseTask.py +2 -2
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/task/TaskExecutor.py +4 -1
- {ok-script-0.0.34 → ok-script-0.0.35}/ok_script.egg-info/PKG-INFO +1 -1
- {ok-script-0.0.34 → ok-script-0.0.35}/setup.py +1 -1
- {ok-script-0.0.34 → ok-script-0.0.35}/README.md +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/OK.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/__init__.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/capture/HwndWindow.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/capture/__init__.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/capture/adb/DeviceManager.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/capture/adb/__init__.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/capture/adb/bin/__init__.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/capture/adb/targets.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/capture/adb/vbox.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/capture/windows/__init__.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/capture/windows/d3d11.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/capture/windows/dump.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/capture/windows/utils.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/capture/windows/window.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/color/Color.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/color/__init__.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/config/Config.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/config/InfoDict.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/config/__init__.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/feature/Box.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/feature/Feature.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/feature/FeatureSet.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/feature/FindFeature.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/feature/__init__.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/gui/TabTitles.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/gui/__init__.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/gui/about/AboutTab.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/gui/about/__init__.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/gui/common/OKIcon.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/gui/common/__init__.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/gui/common/config.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/gui/common/style_sheet.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/gui/debug/AspectRatioWidget.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/gui/debug/DebugTab.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/gui/debug/FrameWidget.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/gui/debug/InfoWidget.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/gui/debug/LoggerWidget.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/gui/debug/Screenshot.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/gui/debug/__init__.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/gui/i18n/__init__.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/gui/i18n/path.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/gui/i18n/update.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/gui/icon/__init__.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/gui/icon/icon.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/gui/overlay/OverlayWindow.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/gui/overlay/__init__.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/gui/qss/__init__.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/gui/resources.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/gui/settings/SettingTab.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/gui/settings/__init__.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/gui/start/SelectCaptureListView.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/gui/start/SelectHwndWindow.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/gui/start/StartCard.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/gui/start/StartTab.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/gui/start/__init__.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/gui/tasks/ConfigItemFactory.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/gui/tasks/ConfigLabelAndWidget.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/gui/tasks/LabelAndDoubleSpinBox.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/gui/tasks/LabelAndDropDown.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/gui/tasks/LabelAndLineEdit.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/gui/tasks/LabelAndList.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/gui/tasks/LabelAndSpinBox.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/gui/tasks/LabelAndSwitchButton.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/gui/tasks/LabelAndWidget.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/gui/tasks/ModifyListDialog.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/gui/tasks/ModifyListItem.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/gui/tasks/StartButton.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/gui/tasks/TaskCard.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/gui/tasks/TaskOpButton.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/gui/tasks/TooltipTableWidget.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/gui/tasks/TriggerTaskTab.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/gui/tasks/__init__.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/gui/util/Alert.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/gui/util/InitWorker.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/gui/util/__init__.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/gui/widget/Card.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/gui/widget/FramelessDialog.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/gui/widget/ListTableWidgetItem.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/gui/widget/NumericTableWidgetItem.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/gui/widget/StatusBar.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/gui/widget/Tab.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/gui/widget/TabWidget.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/gui/widget/UpdateConfigWidgetItem.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/gui/widget/YesNonWidgetItem.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/gui/widget/__init__.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/interaction/ADBInteraction.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/interaction/BaseInteraction.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/interaction/Win32Interaction.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/interaction/__init__.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/logging/__init__.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/ocr/OCR.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/ocr/__init__.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/predict/__init__.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/predict/predict.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/rotypes/Windows/Foundation/Collections.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/rotypes/Windows/Foundation/__init__.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/rotypes/Windows/Globalization/__init__.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/rotypes/Windows/Graphics/Capture/__init__.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/rotypes/Windows/Graphics/DirectX/Direct3D11/__init__.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/rotypes/Windows/Graphics/DirectX/__init__.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/rotypes/Windows/Graphics/Imaging/__init__.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/rotypes/Windows/Graphics/__init__.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/rotypes/Windows/Media/Ocr/__init__.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/rotypes/Windows/Media/__init__.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/rotypes/Windows/Security/Cryptography/__init__.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/rotypes/Windows/Security/__init__.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/rotypes/Windows/Storage/Streams/__init__.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/rotypes/Windows/Storage/__init__.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/rotypes/Windows/__init__.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/rotypes/__init__.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/rotypes/delegate.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/rotypes/export.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/rotypes/idldsl.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/rotypes/inspectable.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/rotypes/roapi.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/rotypes/types.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/rotypes/winstring.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/save/BlackBarProcessor.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/save/PostProcessor.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/save/SaveByInterval.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/save/SaveByKeyPress.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/save/SaveMethodBase.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/save/__init__.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/scene/FeatureScene.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/scene/Scene.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/scene/__init__.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/stats/StreamStats.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/stats/__init__.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/task/ExecutorOperation.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/task/OneTimeTask.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/task/TriggerTask.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/task/__init__.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/util/__init__.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/util/exit_event.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/util/json.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/util/list.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/util/path.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/util/thread.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/util/win32_process.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok/util/yaml.py +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok_script.egg-info/SOURCES.txt +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok_script.egg-info/dependency_links.txt +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok_script.egg-info/requires.txt +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/ok_script.egg-info/top_level.txt +0 -0
- {ok-script-0.0.34 → ok-script-0.0.35}/setup.cfg +0 -0
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import numpy as np
|
|
2
2
|
|
|
3
|
+
class CaptureException(Exception):
|
|
4
|
+
pass
|
|
3
5
|
|
|
4
6
|
class BaseCaptureMethod:
|
|
5
7
|
name = "None"
|
|
@@ -21,6 +23,12 @@ class BaseCaptureMethod:
|
|
|
21
23
|
pass
|
|
22
24
|
|
|
23
25
|
def get_frame(self) -> np.ndarray | None:
|
|
26
|
+
try:
|
|
27
|
+
return self.do_get_frame()
|
|
28
|
+
except Exception as e:
|
|
29
|
+
raise CaptureException() from e
|
|
30
|
+
|
|
31
|
+
def do_get_frame(self):
|
|
24
32
|
pass
|
|
25
33
|
|
|
26
34
|
def draw_rectangle(self):
|
|
@@ -3,16 +3,14 @@ import sys
|
|
|
3
3
|
|
|
4
4
|
from PySide6.QtCore import QSize, QCoreApplication, QLocale, QTranslator, Qt
|
|
5
5
|
from PySide6.QtGui import QIcon
|
|
6
|
-
from PySide6.QtWidgets import QApplication
|
|
6
|
+
from PySide6.QtWidgets import QApplication
|
|
7
7
|
from qfluentwidgets import FluentTranslator, qconfig, Theme
|
|
8
8
|
|
|
9
9
|
import ok
|
|
10
10
|
import ok.gui.resources
|
|
11
|
-
from ok.gui.Communicate import communicate
|
|
12
11
|
from ok.gui.MainWindow import MainWindow
|
|
13
12
|
from ok.gui.i18n.path import i18n_path
|
|
14
13
|
from ok.gui.overlay.OverlayWindow import OverlayWindow
|
|
15
|
-
from ok.gui.start.StartTab import StartTab
|
|
16
14
|
from ok.logging.Logger import get_logger
|
|
17
15
|
|
|
18
16
|
logger = get_logger(__name__)
|
|
@@ -45,7 +43,6 @@ class App:
|
|
|
45
43
|
self.main_window = None
|
|
46
44
|
self.exit_event = exit_event
|
|
47
45
|
self.icon = QIcon(self.config.get('gui_icon') or ":/icon/icon.ico")
|
|
48
|
-
self.tray = QSystemTrayIcon(self.icon)
|
|
49
46
|
|
|
50
47
|
translator = QTranslator(self.app)
|
|
51
48
|
full_path = os.path.join(i18n_path, f"{self.locale.name()}")
|
|
@@ -57,30 +54,6 @@ class App:
|
|
|
57
54
|
else:
|
|
58
55
|
logger.debug(f"No translation available for {self.locale}, falling back to English/default. {full_path}")
|
|
59
56
|
|
|
60
|
-
# Create a context menu for the tray
|
|
61
|
-
menu = QMenu()
|
|
62
|
-
exit_action = menu.addAction(self.app.tr("Exit"))
|
|
63
|
-
exit_action.triggered.connect(self.quit)
|
|
64
|
-
|
|
65
|
-
# Set the context menu and show the tray icon
|
|
66
|
-
self.tray.setContextMenu(menu)
|
|
67
|
-
self.tray.show()
|
|
68
|
-
|
|
69
|
-
communicate.notification.connect(self.show_notification)
|
|
70
|
-
|
|
71
|
-
def show_notification(self, title, message):
|
|
72
|
-
if title is None:
|
|
73
|
-
title = self.title
|
|
74
|
-
self.tray.showMessage(title, message)
|
|
75
|
-
|
|
76
|
-
def show(self):
|
|
77
|
-
self.loading_window = StartTab(self, self.exit_event)
|
|
78
|
-
size = self.size_relative_to_screen(width=0.6, height=0.4)
|
|
79
|
-
self.loading_window.resize(size)
|
|
80
|
-
self.loading_window.setMinimumSize(size)
|
|
81
|
-
self.center_window(self.loading_window)
|
|
82
|
-
self.loading_window.show()
|
|
83
|
-
|
|
84
57
|
def center_window(self, window):
|
|
85
58
|
screen = self.app.primaryScreen()
|
|
86
59
|
size = screen.size()
|
|
@@ -91,7 +64,7 @@ class App:
|
|
|
91
64
|
window.move(half_screen_width / 2, half_screen_height / 2)
|
|
92
65
|
|
|
93
66
|
def show_main_window(self):
|
|
94
|
-
self.main_window = MainWindow(self.overlay, self.about, exit_event=self.exit_event)
|
|
67
|
+
self.main_window = MainWindow(self.icon, self.overlay, self.about, exit_event=self.exit_event)
|
|
95
68
|
self.main_window.setWindowTitle(f'{self.title} {self.version}') # Set the window title here
|
|
96
69
|
self.main_window.setWindowIcon(self.icon)
|
|
97
70
|
if self.overlay and ok.gui.device_manager.hwnd is not None:
|
|
@@ -119,7 +92,3 @@ class App:
|
|
|
119
92
|
|
|
120
93
|
def exec(self):
|
|
121
94
|
sys.exit(self.app.exec())
|
|
122
|
-
|
|
123
|
-
def quit(self):
|
|
124
|
-
ok.gui.ok.quit()
|
|
125
|
-
self.app.quit()
|
|
@@ -12,12 +12,13 @@ class Communicate(QObject):
|
|
|
12
12
|
task_info = Signal()
|
|
13
13
|
window = Signal(bool, int, int, int, int, int, int, float)
|
|
14
14
|
loading_progress = Signal(str)
|
|
15
|
-
notification = Signal(str, str)
|
|
15
|
+
notification = Signal(str, str, bool)
|
|
16
16
|
executor_paused: Signal = Signal(bool)
|
|
17
17
|
screenshot = Signal(np.ndarray, str)
|
|
18
18
|
update_overlay = Signal()
|
|
19
19
|
adb_devices: Signal = Signal(bool)
|
|
20
20
|
tab = Signal(str)
|
|
21
|
+
capture_error = Signal()
|
|
21
22
|
|
|
22
23
|
def emit_draw_box(self, key: str = None, boxes=None, color=None, frame=None):
|
|
23
24
|
self.draw_box.emit(key, boxes, color, frame)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
from PySide6.QtCore import QObject, Signal, Qt
|
|
2
2
|
from PySide6.QtGui import QKeySequence, QShortcut
|
|
3
|
+
from PySide6.QtWidgets import QMenu, QSystemTrayIcon
|
|
3
4
|
from qfluentwidgets import FluentIcon, NavigationItemPosition, MSFluentWindow, InfoBar, InfoBarPosition, MessageBox
|
|
4
5
|
|
|
5
6
|
import ok.gui
|
|
@@ -19,7 +20,7 @@ class Communicate(QObject):
|
|
|
19
20
|
|
|
20
21
|
|
|
21
22
|
class MainWindow(MSFluentWindow):
|
|
22
|
-
def __init__(self, debug=False, about=None, exit_event=None):
|
|
23
|
+
def __init__(self, icon, debug=False, about=None, exit_event=None):
|
|
23
24
|
super().__init__()
|
|
24
25
|
self.exit_event = exit_event
|
|
25
26
|
self.start_tab = StartTab()
|
|
@@ -53,6 +54,41 @@ class MainWindow(MSFluentWindow):
|
|
|
53
54
|
self.shortcut = QShortcut(QKeySequence("Ctrl+Alt+D"), self)
|
|
54
55
|
self.shortcut.activated.connect(dump_threads)
|
|
55
56
|
|
|
57
|
+
# Create a context menu for the tray
|
|
58
|
+
menu = QMenu()
|
|
59
|
+
exit_action = menu.addAction(self.tr("Exit"))
|
|
60
|
+
exit_action.triggered.connect(ok.gui.ok.quit)
|
|
61
|
+
|
|
62
|
+
self.tray = QSystemTrayIcon(icon)
|
|
63
|
+
|
|
64
|
+
# Set the context menu and show the tray icon
|
|
65
|
+
self.tray.setContextMenu(menu)
|
|
66
|
+
self.tray.show()
|
|
67
|
+
|
|
68
|
+
communicate.capture_error.connect(self.capture_error)
|
|
69
|
+
communicate.notification.connect(self.show_notification)
|
|
70
|
+
|
|
71
|
+
def show_notification(self, message, title=None, error=None):
|
|
72
|
+
bar = InfoBar.error if error else InfoBar.info
|
|
73
|
+
if title is None:
|
|
74
|
+
title = f"{self.tr('Error') if error else 'Info'}:"
|
|
75
|
+
bar(
|
|
76
|
+
title=title,
|
|
77
|
+
content=message,
|
|
78
|
+
orient=Qt.Horizontal,
|
|
79
|
+
isClosable=True,
|
|
80
|
+
position=InfoBarPosition.TOP,
|
|
81
|
+
duration=5000, # won't disappear automatically
|
|
82
|
+
parent=self.window()
|
|
83
|
+
)
|
|
84
|
+
if title is None:
|
|
85
|
+
title = self.title
|
|
86
|
+
self.tray.showMessage(title, message)
|
|
87
|
+
|
|
88
|
+
def capture_error(self):
|
|
89
|
+
self.show_notification(self.tr('Please check whether the game window is selected correctly!'),
|
|
90
|
+
self.tr('Capture Error'), error=True)
|
|
91
|
+
|
|
56
92
|
def navigate_tab(self, index):
|
|
57
93
|
if index == "start":
|
|
58
94
|
self.switchTo(self.start_tab)
|
|
@@ -35,8 +35,7 @@ class OneTimeTaskTab(Tab):
|
|
|
35
35
|
communicate.task_info.connect(self.update_info_table)
|
|
36
36
|
|
|
37
37
|
def task_update(self, task):
|
|
38
|
-
|
|
39
|
-
self.update_info_table()
|
|
38
|
+
self.update_info_table()
|
|
40
39
|
|
|
41
40
|
def update_info_table(self):
|
|
42
41
|
task = ok.gui.executor.current_task
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import logging
|
|
2
2
|
import os
|
|
3
|
+
import sys
|
|
3
4
|
import traceback
|
|
4
|
-
import ok
|
|
5
5
|
from logging.handlers import TimedRotatingFileHandler
|
|
6
6
|
|
|
7
|
+
import ok
|
|
7
8
|
from ok.util.path import get_path_relative_to_exe, ensure_dir_for_file
|
|
8
9
|
|
|
9
10
|
|
|
@@ -34,6 +35,13 @@ def get_substring_from_last_dot_exclusive(s):
|
|
|
34
35
|
auto_helper_logger = logging.getLogger("ok")
|
|
35
36
|
|
|
36
37
|
|
|
38
|
+
def log_exception_handler(exctype, value, traceback):
|
|
39
|
+
if auto_helper_logger is not None:
|
|
40
|
+
auto_helper_logger.error(f"Uncaught exception: {exctype}, traceback: {traceback}")
|
|
41
|
+
# Call the default excepthook to print the traceback
|
|
42
|
+
sys.__excepthook__(exctype, value, traceback)
|
|
43
|
+
|
|
44
|
+
|
|
37
45
|
def config_logger(config):
|
|
38
46
|
if config.get('debug'):
|
|
39
47
|
auto_helper_logger.setLevel(logging.DEBUG)
|
|
@@ -70,6 +78,8 @@ def config_logger(config):
|
|
|
70
78
|
file_handler.setLevel(logging.ERROR) # File handler level
|
|
71
79
|
auto_helper_logger.addHandler(file_handler)
|
|
72
80
|
|
|
81
|
+
sys.excepthook = log_exception_handler
|
|
82
|
+
|
|
73
83
|
|
|
74
84
|
class Logger:
|
|
75
85
|
def __init__(self, name):
|
|
@@ -64,8 +64,8 @@ class BaseTask(ExecutorOperation):
|
|
|
64
64
|
communicate.task_info.emit()
|
|
65
65
|
|
|
66
66
|
@staticmethod
|
|
67
|
-
def notification(message, title=None):
|
|
68
|
-
communicate.notification.emit(title,
|
|
67
|
+
def notification(message, title=None, error=False):
|
|
68
|
+
communicate.notification.emit(message, title, error)
|
|
69
69
|
|
|
70
70
|
@property
|
|
71
71
|
def enabled(self):
|
|
@@ -2,6 +2,7 @@ import threading
|
|
|
2
2
|
import time
|
|
3
3
|
import traceback
|
|
4
4
|
|
|
5
|
+
from ok.capture.BaseCaptureMethod import CaptureException
|
|
5
6
|
from ok.capture.adb.DeviceManager import DeviceManager
|
|
6
7
|
from ok.gui.Communicate import communicate
|
|
7
8
|
from ok.logging.Logger import get_logger
|
|
@@ -227,10 +228,12 @@ class TaskExecutor:
|
|
|
227
228
|
logger.info(f"FinishedException, breaking")
|
|
228
229
|
break
|
|
229
230
|
except Exception as e:
|
|
231
|
+
if isinstance(e, CaptureException):
|
|
232
|
+
communicate.capture_error.emit()
|
|
230
233
|
name = ""
|
|
231
234
|
if self.current_task is not None:
|
|
232
|
-
self.current_task.disable()
|
|
233
235
|
name = self.current_task.name
|
|
236
|
+
self.current_task.disable()
|
|
234
237
|
traceback.print_exc()
|
|
235
238
|
stack_trace_str = traceback.format_exc()
|
|
236
239
|
logger.error(f"{name} exception: {e}, traceback: {stack_trace_str}")
|
|
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.34 → ok-script-0.0.35}/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
|