ok-script 0.0.35__tar.gz → 0.0.37__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.35 → ok-script-0.0.37}/PKG-INFO +4 -27
- ok-script-0.0.37/README.md +24 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/capture/HwndWindow.py +5 -1
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/capture/adb/ADBCaptureMethod.py +14 -19
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/capture/adb/DeviceManager.py +10 -4
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/gui/start/StartCard.py +4 -4
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/interaction/ADBInteraction.py +1 -1
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/task/BaseTask.py +3 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok_script.egg-info/PKG-INFO +4 -27
- {ok-script-0.0.35 → ok-script-0.0.37}/ok_script.egg-info/SOURCES.txt +0 -2
- {ok-script-0.0.35 → ok-script-0.0.37}/setup.py +1 -1
- ok-script-0.0.35/README.md +0 -47
- ok-script-0.0.35/ok/predict/predict.py +0 -45
- ok-script-0.0.35/ok/util/__init__.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/OK.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/__init__.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/capture/BaseCaptureMethod.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/capture/__init__.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/capture/adb/__init__.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/capture/adb/bin/__init__.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/capture/adb/targets.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/capture/adb/vbox.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/capture/windows/WindowsGraphicsCaptureMethod.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/capture/windows/__init__.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/capture/windows/d3d11.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/capture/windows/dump.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/capture/windows/utils.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/capture/windows/window.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/color/Color.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/color/__init__.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/config/Config.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/config/InfoDict.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/config/__init__.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/feature/Box.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/feature/Feature.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/feature/FeatureSet.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/feature/FindFeature.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/feature/__init__.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/gui/App.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/gui/Communicate.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/gui/MainWindow.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/gui/TabTitles.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/gui/__init__.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/gui/about/AboutTab.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/gui/about/__init__.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/gui/common/OKIcon.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/gui/common/__init__.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/gui/common/config.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/gui/common/style_sheet.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/gui/debug/AspectRatioWidget.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/gui/debug/DebugTab.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/gui/debug/FrameWidget.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/gui/debug/InfoWidget.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/gui/debug/LoggerWidget.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/gui/debug/Screenshot.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/gui/debug/__init__.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/gui/i18n/__init__.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/gui/i18n/path.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/gui/i18n/update.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/gui/icon/__init__.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/gui/icon/icon.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/gui/overlay/OverlayWindow.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/gui/overlay/__init__.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/gui/qss/__init__.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/gui/resources.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/gui/settings/SettingTab.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/gui/settings/__init__.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/gui/start/SelectCaptureListView.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/gui/start/SelectHwndWindow.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/gui/start/StartTab.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/gui/start/__init__.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/gui/tasks/ConfigItemFactory.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/gui/tasks/ConfigLabelAndWidget.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/gui/tasks/LabelAndDoubleSpinBox.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/gui/tasks/LabelAndDropDown.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/gui/tasks/LabelAndLineEdit.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/gui/tasks/LabelAndList.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/gui/tasks/LabelAndSpinBox.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/gui/tasks/LabelAndSwitchButton.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/gui/tasks/LabelAndWidget.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/gui/tasks/ModifyListDialog.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/gui/tasks/ModifyListItem.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/gui/tasks/OneTimeTaskTab.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/gui/tasks/StartButton.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/gui/tasks/TaskCard.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/gui/tasks/TaskOpButton.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/gui/tasks/TooltipTableWidget.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/gui/tasks/TriggerTaskTab.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/gui/tasks/__init__.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/gui/util/Alert.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/gui/util/InitWorker.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/gui/util/__init__.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/gui/widget/Card.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/gui/widget/FramelessDialog.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/gui/widget/ListTableWidgetItem.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/gui/widget/NumericTableWidgetItem.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/gui/widget/StatusBar.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/gui/widget/Tab.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/gui/widget/TabWidget.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/gui/widget/UpdateConfigWidgetItem.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/gui/widget/YesNonWidgetItem.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/gui/widget/__init__.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/interaction/BaseInteraction.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/interaction/Win32Interaction.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/interaction/__init__.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/logging/Logger.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/logging/__init__.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/ocr/OCR.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/ocr/__init__.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/rotypes/Windows/Foundation/Collections.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/rotypes/Windows/Foundation/__init__.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/rotypes/Windows/Globalization/__init__.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/rotypes/Windows/Graphics/Capture/__init__.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/rotypes/Windows/Graphics/DirectX/Direct3D11/__init__.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/rotypes/Windows/Graphics/DirectX/__init__.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/rotypes/Windows/Graphics/Imaging/__init__.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/rotypes/Windows/Graphics/__init__.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/rotypes/Windows/Media/Ocr/__init__.py +0 -0
- {ok-script-0.0.35/ok/predict → ok-script-0.0.37/ok/rotypes/Windows/Media}/__init__.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/rotypes/Windows/Security/Cryptography/__init__.py +0 -0
- {ok-script-0.0.35/ok/rotypes/Windows/Media → ok-script-0.0.37/ok/rotypes/Windows/Security}/__init__.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/rotypes/Windows/Storage/Streams/__init__.py +0 -0
- {ok-script-0.0.35/ok/rotypes/Windows/Security → ok-script-0.0.37/ok/rotypes/Windows/Storage}/__init__.py +0 -0
- {ok-script-0.0.35/ok/rotypes/Windows/Storage → ok-script-0.0.37/ok/rotypes/Windows}/__init__.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/rotypes/__init__.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/rotypes/delegate.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/rotypes/export.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/rotypes/idldsl.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/rotypes/inspectable.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/rotypes/roapi.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/rotypes/types.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/rotypes/winstring.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/save/BlackBarProcessor.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/save/PostProcessor.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/save/SaveByInterval.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/save/SaveByKeyPress.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/save/SaveMethodBase.py +0 -0
- {ok-script-0.0.35/ok/rotypes/Windows → ok-script-0.0.37/ok/save}/__init__.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/scene/FeatureScene.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/scene/Scene.py +0 -0
- {ok-script-0.0.35/ok/save → ok-script-0.0.37/ok/scene}/__init__.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/stats/StreamStats.py +0 -0
- {ok-script-0.0.35/ok/scene → ok-script-0.0.37/ok/stats}/__init__.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/task/ExecutorOperation.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/task/OneTimeTask.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/task/TaskExecutor.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/task/TriggerTask.py +0 -0
- {ok-script-0.0.35/ok/stats → ok-script-0.0.37/ok/task}/__init__.py +0 -0
- {ok-script-0.0.35/ok/task → ok-script-0.0.37/ok/util}/__init__.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/util/exit_event.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/util/json.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/util/list.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/util/path.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/util/thread.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/util/win32_process.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok/util/yaml.py +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok_script.egg-info/dependency_links.txt +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok_script.egg-info/requires.txt +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/ok_script.egg-info/top_level.txt +0 -0
- {ok-script-0.0.35 → ok-script-0.0.37}/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.37
|
|
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
|
|
@@ -33,37 +33,14 @@ Requires-Dist: opencv-python==4.9.0.80
|
|
|
33
33
|
5. 支持Python3.7以上版本
|
|
34
34
|
6. 学习成本低, 自定义函数少, 也可以直接使用opencv, RapidOCR等api
|
|
35
35
|
|
|
36
|
-
## Example Usage
|
|
37
36
|
|
|
38
|
-
|
|
39
|
-
[
|
|
37
|
+
## 目前有两个已完成项目:
|
|
38
|
+
基于OCR,白荆回廊自动凹技能,可以连续跑几个小时的自动脚本[https://github.com/ok-oldking/ok-baijing](https://github.com/ok-oldking/ok-baijing)
|
|
40
39
|
|
|
41
|
-
|
|
42
|
-
# Defining game scenes to handle different in-game situations through automated tasks
|
|
43
|
-
task_executor.scenes.extend([
|
|
44
|
-
WorldScene(interaction, feature_set),
|
|
45
|
-
StartScene(interaction, feature_set),
|
|
46
|
-
MonthlyCardScene(interaction, feature_set),
|
|
47
|
-
DialogCloseButtonScene(interaction, feature_set),
|
|
48
|
-
DialogChoicesScene(interaction, feature_set),
|
|
49
|
-
DialogPlayingScene(interaction, feature_set),
|
|
50
|
-
BlackDialogScene(interaction, feature_set),
|
|
51
|
-
])
|
|
40
|
+
触发式任务,原神自动拾取, 跳过剧情等[https://github.com/ok-oldking/ok-genshin](https://github.com/ok-oldking/ok-genshin)
|
|
52
41
|
|
|
53
|
-
# Adding automated tasks for gameplay, such as dialog navigation and item collection
|
|
54
|
-
task_executor.tasks.extend([
|
|
55
|
-
AutoPlayDialogTask(interaction, feature_set), # speeding up the dialogs
|
|
56
|
-
AutoChooseDialogTask(interaction, feature_set), # choose dialog options
|
|
57
|
-
AutoPickTask(interaction, feature_set), # pickup items in world scene
|
|
58
|
-
AutoLoginTask(interaction, feature_set), # auto login and claim rewards
|
|
59
|
-
])
|
|
60
|
-
```
|
|
61
42
|
|
|
62
43
|
## Scenes
|
|
63
44
|
|
|
64
45
|
## Tasks
|
|
65
46
|
|
|
66
|
-
## Project Structure
|
|
67
|
-
|
|
68
|
-
- `autoui`: Framework code.
|
|
69
|
-
- `genshin`: Example Genshin Impact automation project
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# ok-script
|
|
2
|
+
|
|
3
|
+
类似于AirScript, 使用Python
|
|
4
|
+
|
|
5
|
+
## 优势
|
|
6
|
+
|
|
7
|
+
1. 开源免费, 依赖库均为开源方案, 支持pip install任何第三方库
|
|
8
|
+
2. 代码和打包流程完全由开发者控制, 不会上传服务器, 没有安全性隐患, 不容易被侦测和识别
|
|
9
|
+
3. 一套代码即可支持Windows安卓模拟器/ADB连接的虚拟机, Windows客户端游戏, 安卓系统直接运行(开发中)
|
|
10
|
+
4. 支持GUI以及Console运行, 也可以完全自己开发GUI
|
|
11
|
+
5. 支持Python3.7以上版本
|
|
12
|
+
6. 学习成本低, 自定义函数少, 也可以直接使用opencv, RapidOCR等api
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
## 目前有两个已完成项目:
|
|
16
|
+
基于OCR,白荆回廊自动凹技能,可以连续跑几个小时的自动脚本[https://github.com/ok-oldking/ok-baijing](https://github.com/ok-oldking/ok-baijing)
|
|
17
|
+
|
|
18
|
+
触发式任务,原神自动拾取, 跳过剧情等[https://github.com/ok-oldking/ok-genshin](https://github.com/ok-oldking/ok-genshin)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
## Scenes
|
|
22
|
+
|
|
23
|
+
## Tasks
|
|
24
|
+
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# original https://github.com/dantmnf & https://github.com/hakaboom/winAuto
|
|
2
2
|
import ctypes
|
|
3
|
+
import os
|
|
3
4
|
import re
|
|
4
5
|
import threading
|
|
5
6
|
import time
|
|
@@ -194,7 +195,10 @@ def get_exe_name_by_hwnd(hwnd):
|
|
|
194
195
|
exe_name = ctypes.create_unicode_buffer(1024)
|
|
195
196
|
GetModuleFileNameExW(h_process, None, exe_name, 1024)
|
|
196
197
|
|
|
198
|
+
# Extract the executable name from the full path
|
|
199
|
+
exe_only_name = os.path.basename(exe_name.value)
|
|
200
|
+
|
|
197
201
|
# Close the process handle
|
|
198
202
|
CloseHandle(h_process)
|
|
199
203
|
|
|
200
|
-
return
|
|
204
|
+
return exe_only_name
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
# original https://github.com/Toufool/AutoSplit/blob/master/src/capture_method/WindowsGraphicsCaptureMethod.py
|
|
2
2
|
import cv2
|
|
3
3
|
import numpy as np
|
|
4
|
-
from adbutils import AdbError
|
|
5
4
|
from typing_extensions import override
|
|
6
5
|
|
|
7
6
|
from ok.capture.BaseCaptureMethod import BaseCaptureMethod
|
|
@@ -14,12 +13,12 @@ class ADBCaptureMethod(BaseCaptureMethod):
|
|
|
14
13
|
name = "ADB command line Capture"
|
|
15
14
|
description = "use the adb screencap command, slow but works when in background/minimized, takes 300ms per frame"
|
|
16
15
|
|
|
17
|
-
def __init__(self,
|
|
16
|
+
def __init__(self, device_manager, exit_event, width=0, height=0):
|
|
18
17
|
super().__init__()
|
|
19
18
|
self.exit_event = exit_event
|
|
20
19
|
self._size = (width, height)
|
|
21
20
|
self._connected = (width != 0 and height != 0)
|
|
22
|
-
self.
|
|
21
|
+
self.device_manager = device_manager
|
|
23
22
|
|
|
24
23
|
@property
|
|
25
24
|
def width(self):
|
|
@@ -40,7 +39,7 @@ class ADBCaptureMethod(BaseCaptureMethod):
|
|
|
40
39
|
def screencap(self):
|
|
41
40
|
if self.exit_event.is_set():
|
|
42
41
|
return None
|
|
43
|
-
frame = do_screencap(self.
|
|
42
|
+
frame = do_screencap(self.device_manager)
|
|
44
43
|
if frame is not None:
|
|
45
44
|
height, width, _ = frame.shape
|
|
46
45
|
self._connected = True
|
|
@@ -50,21 +49,17 @@ class ADBCaptureMethod(BaseCaptureMethod):
|
|
|
50
49
|
return frame
|
|
51
50
|
|
|
52
51
|
def connected(self):
|
|
53
|
-
if not self._connected and self.device is not None:
|
|
52
|
+
if not self._connected and self.device_manager.device is not None:
|
|
54
53
|
self.screencap()
|
|
55
|
-
return self._connected and self.device is not None
|
|
54
|
+
return self._connected and self.device_manager.device is not None
|
|
56
55
|
|
|
57
56
|
|
|
58
|
-
def do_screencap(
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
else:
|
|
68
|
-
logger.error(f"Screencap image decode error, probably disconnected")
|
|
69
|
-
except AdbError as e:
|
|
70
|
-
logger.error(f"Device {device} error", e)
|
|
57
|
+
def do_screencap(device_manager) -> np.ndarray | None:
|
|
58
|
+
png_bytes = device_manager.shell("screencap -p", encoding=None)
|
|
59
|
+
if png_bytes is not None and len(png_bytes) > 0:
|
|
60
|
+
image_data = np.frombuffer(png_bytes, dtype=np.uint8)
|
|
61
|
+
image = cv2.imdecode(image_data, cv2.IMREAD_COLOR)
|
|
62
|
+
if image is not None:
|
|
63
|
+
return image
|
|
64
|
+
else:
|
|
65
|
+
logger.error(f"Screencap image decode error, probably disconnected")
|
|
@@ -2,6 +2,7 @@ import threading
|
|
|
2
2
|
|
|
3
3
|
import adbutils
|
|
4
4
|
import win32gui
|
|
5
|
+
from adbutils import AdbError
|
|
5
6
|
|
|
6
7
|
from ok.capture.HwndWindow import HwndWindow, find_hwnd_by_title_and_exe
|
|
7
8
|
from ok.capture.adb.ADBCaptureMethod import ADBCaptureMethod, do_screencap
|
|
@@ -54,7 +55,7 @@ class DeviceManager:
|
|
|
54
55
|
except Exception as e:
|
|
55
56
|
logger.error("adb connect error", e)
|
|
56
57
|
self._connect_all = True
|
|
57
|
-
logger.debug(f'connect_all
|
|
58
|
+
logger.debug(f'connect_all')
|
|
58
59
|
|
|
59
60
|
def get_devices(self):
|
|
60
61
|
return list(self.device_dict.values())
|
|
@@ -217,7 +218,7 @@ class DeviceManager:
|
|
|
217
218
|
elif not isinstance(self.capture_method, ADBCaptureMethod):
|
|
218
219
|
if self.capture_method is not None:
|
|
219
220
|
self.capture_method.close()
|
|
220
|
-
self.capture_method = ADBCaptureMethod(self
|
|
221
|
+
self.capture_method = ADBCaptureMethod(self, self.exit_event, width=width,
|
|
221
222
|
height=height)
|
|
222
223
|
self.interaction = ADBBaseInteraction(self, self.capture_method, width, height)
|
|
223
224
|
if self.debug and hwnd_name:
|
|
@@ -255,5 +256,10 @@ class DeviceManager:
|
|
|
255
256
|
if device is not None:
|
|
256
257
|
try:
|
|
257
258
|
return device.shell(*args, **kwargs)
|
|
258
|
-
except
|
|
259
|
-
|
|
259
|
+
except AdbError as e:
|
|
260
|
+
addr = self.get_preferred_device()['address']
|
|
261
|
+
self.adb.connect(addr)
|
|
262
|
+
logger.error(f"shell_wrapper error occurred: {e} ,try reconnect {addr}")
|
|
263
|
+
return device.shell(*args, **kwargs)
|
|
264
|
+
else:
|
|
265
|
+
raise Exception('Device is none')
|
|
@@ -80,12 +80,12 @@ class StartCard(SettingCard):
|
|
|
80
80
|
if not ok.gui.executor.connected():
|
|
81
81
|
self.status_bar.setTitle(self.tr("Game Window Disconnected"))
|
|
82
82
|
self.status_bar.setState(True)
|
|
83
|
-
elif task := ok.gui.executor.current_task:
|
|
84
|
-
self.status_bar.setTitle(self.tr("Running") + ": " + task.name)
|
|
85
|
-
self.status_bar.setState(False)
|
|
86
83
|
elif active_trigger_task_count := ok.gui.executor.active_trigger_task_count():
|
|
87
84
|
self.status_bar.setTitle(
|
|
88
|
-
self.tr("Running") + ": " + str(active_trigger_task_count) + self.tr("
|
|
85
|
+
self.tr("Running") + ": " + str(active_trigger_task_count) + ' ' + self.tr("Trigger Tasks"))
|
|
86
|
+
self.status_bar.setState(False)
|
|
87
|
+
elif task := ok.gui.executor.current_task:
|
|
88
|
+
self.status_bar.setTitle(self.tr("Running") + ": " + task.name)
|
|
89
89
|
self.status_bar.setState(False)
|
|
90
90
|
else:
|
|
91
91
|
self.status_bar.setTitle(self.tr("Waiting for task to be enabled"))
|
|
@@ -27,4 +27,4 @@ class ADBBaseInteraction(BaseInteraction):
|
|
|
27
27
|
super().click(x, y)
|
|
28
28
|
x = int(x * self.width / self.capture.width)
|
|
29
29
|
y = int(y * self.height / self.capture.height)
|
|
30
|
-
self.device_manager.
|
|
30
|
+
self.device_manager.shell(f"input tap {x} {y}")
|
|
@@ -93,6 +93,9 @@ class BaseTask(ExecutorOperation):
|
|
|
93
93
|
def info_set(self, key, value):
|
|
94
94
|
self.info[key] = value
|
|
95
95
|
|
|
96
|
+
def info_add(self, key, count=1):
|
|
97
|
+
self.info[key] = self.info.get(key, 0) + count
|
|
98
|
+
|
|
96
99
|
def load_config(self, folder):
|
|
97
100
|
self.config = Config(self.default_config, folder, self.__class__.__name__)
|
|
98
101
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: ok-script
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.37
|
|
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
|
|
@@ -33,37 +33,14 @@ Requires-Dist: opencv-python==4.9.0.80
|
|
|
33
33
|
5. 支持Python3.7以上版本
|
|
34
34
|
6. 学习成本低, 自定义函数少, 也可以直接使用opencv, RapidOCR等api
|
|
35
35
|
|
|
36
|
-
## Example Usage
|
|
37
36
|
|
|
38
|
-
|
|
39
|
-
[
|
|
37
|
+
## 目前有两个已完成项目:
|
|
38
|
+
基于OCR,白荆回廊自动凹技能,可以连续跑几个小时的自动脚本[https://github.com/ok-oldking/ok-baijing](https://github.com/ok-oldking/ok-baijing)
|
|
40
39
|
|
|
41
|
-
|
|
42
|
-
# Defining game scenes to handle different in-game situations through automated tasks
|
|
43
|
-
task_executor.scenes.extend([
|
|
44
|
-
WorldScene(interaction, feature_set),
|
|
45
|
-
StartScene(interaction, feature_set),
|
|
46
|
-
MonthlyCardScene(interaction, feature_set),
|
|
47
|
-
DialogCloseButtonScene(interaction, feature_set),
|
|
48
|
-
DialogChoicesScene(interaction, feature_set),
|
|
49
|
-
DialogPlayingScene(interaction, feature_set),
|
|
50
|
-
BlackDialogScene(interaction, feature_set),
|
|
51
|
-
])
|
|
40
|
+
触发式任务,原神自动拾取, 跳过剧情等[https://github.com/ok-oldking/ok-genshin](https://github.com/ok-oldking/ok-genshin)
|
|
52
41
|
|
|
53
|
-
# Adding automated tasks for gameplay, such as dialog navigation and item collection
|
|
54
|
-
task_executor.tasks.extend([
|
|
55
|
-
AutoPlayDialogTask(interaction, feature_set), # speeding up the dialogs
|
|
56
|
-
AutoChooseDialogTask(interaction, feature_set), # choose dialog options
|
|
57
|
-
AutoPickTask(interaction, feature_set), # pickup items in world scene
|
|
58
|
-
AutoLoginTask(interaction, feature_set), # auto login and claim rewards
|
|
59
|
-
])
|
|
60
|
-
```
|
|
61
42
|
|
|
62
43
|
## Scenes
|
|
63
44
|
|
|
64
45
|
## Tasks
|
|
65
46
|
|
|
66
|
-
## Project Structure
|
|
67
|
-
|
|
68
|
-
- `autoui`: Framework code.
|
|
69
|
-
- `genshin`: Example Genshin Impact automation project
|
ok-script-0.0.35/README.md
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
# ok-script
|
|
2
|
-
|
|
3
|
-
类似于AirScript, 使用Python
|
|
4
|
-
|
|
5
|
-
## 优势
|
|
6
|
-
|
|
7
|
-
1. 开源免费, 依赖库均为开源方案, 支持pip install任何第三方库
|
|
8
|
-
2. 代码和打包流程完全由开发者控制, 不会上传服务器, 没有安全性隐患, 不容易被侦测和识别
|
|
9
|
-
3. 一套代码即可支持Windows安卓模拟器/ADB连接的虚拟机, Windows客户端游戏, 安卓系统直接运行(开发中)
|
|
10
|
-
4. 支持GUI以及Console运行, 也可以完全自己开发GUI
|
|
11
|
-
5. 支持Python3.7以上版本
|
|
12
|
-
6. 学习成本低, 自定义函数少, 也可以直接使用opencv, RapidOCR等api
|
|
13
|
-
|
|
14
|
-
## Example Usage
|
|
15
|
-
|
|
16
|
-
Basically you only need to write the Tasks and Scenes, the autoui framework will do all the heavy lifting.
|
|
17
|
-
[genshin/main.py](genshin/main.py)
|
|
18
|
-
|
|
19
|
-
```python
|
|
20
|
-
# Defining game scenes to handle different in-game situations through automated tasks
|
|
21
|
-
task_executor.scenes.extend([
|
|
22
|
-
WorldScene(interaction, feature_set),
|
|
23
|
-
StartScene(interaction, feature_set),
|
|
24
|
-
MonthlyCardScene(interaction, feature_set),
|
|
25
|
-
DialogCloseButtonScene(interaction, feature_set),
|
|
26
|
-
DialogChoicesScene(interaction, feature_set),
|
|
27
|
-
DialogPlayingScene(interaction, feature_set),
|
|
28
|
-
BlackDialogScene(interaction, feature_set),
|
|
29
|
-
])
|
|
30
|
-
|
|
31
|
-
# Adding automated tasks for gameplay, such as dialog navigation and item collection
|
|
32
|
-
task_executor.tasks.extend([
|
|
33
|
-
AutoPlayDialogTask(interaction, feature_set), # speeding up the dialogs
|
|
34
|
-
AutoChooseDialogTask(interaction, feature_set), # choose dialog options
|
|
35
|
-
AutoPickTask(interaction, feature_set), # pickup items in world scene
|
|
36
|
-
AutoLoginTask(interaction, feature_set), # auto login and claim rewards
|
|
37
|
-
])
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
## Scenes
|
|
41
|
-
|
|
42
|
-
## Tasks
|
|
43
|
-
|
|
44
|
-
## Project Structure
|
|
45
|
-
|
|
46
|
-
- `autoui`: Framework code.
|
|
47
|
-
- `genshin`: Example Genshin Impact automation project
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import torch
|
|
2
|
-
from PIL import Image, ImageDraw
|
|
3
|
-
import numpy as np
|
|
4
|
-
from ultralytics import YOLO
|
|
5
|
-
|
|
6
|
-
# Load the model
|
|
7
|
-
# model = torch.hub.load('ultralytics/yolov8', 'custom', path='models/best.pt')
|
|
8
|
-
model = YOLO('models/best.pt') # pretrained YOLOv8n model
|
|
9
|
-
|
|
10
|
-
# Run batched inference on a list of images
|
|
11
|
-
# results = model(['im1.jpg', 'im2.jpg']) # return a list of Results objects
|
|
12
|
-
|
|
13
|
-
# Load an image
|
|
14
|
-
image_path = 'images/3.jpg'
|
|
15
|
-
image = Image.open(image_path)
|
|
16
|
-
|
|
17
|
-
# Perform inference
|
|
18
|
-
results = model(image)
|
|
19
|
-
|
|
20
|
-
# Extract data
|
|
21
|
-
for result in results:
|
|
22
|
-
boxes = result.boxes # Boxes object for bbox outputs
|
|
23
|
-
print(boxes)
|
|
24
|
-
masks = result.masks # Masks object for segmentation masks outputs
|
|
25
|
-
keypoints = result.keypoints # Keypoints object for pose outputs
|
|
26
|
-
probs = result.probs # Probs object for classification outputs
|
|
27
|
-
|
|
28
|
-
for r in results:
|
|
29
|
-
im_array = r.plot() # plot a BGR numpy array of predictions
|
|
30
|
-
im = Image.fromarray(im_array[..., ::-1]) # RGB PIL image
|
|
31
|
-
im.show() # show image
|
|
32
|
-
im.save('results.jpg') # save image
|
|
33
|
-
# labels, cord = results.xyxyn[0][:, -1], results.xyxyn[0][:, :-1]
|
|
34
|
-
|
|
35
|
-
# # Draw bounding boxes and labels
|
|
36
|
-
# draw = ImageDraw.Draw(image)
|
|
37
|
-
# for label, (*xyxy,) in zip(labels, cord):
|
|
38
|
-
# label = model.module.names[int(label)] # Get label name
|
|
39
|
-
# xyxy = (xyxy * np.array([image.width, image.height, image.width, image.height])).tolist() # Scale coords
|
|
40
|
-
# draw.rectangle(xyxy, outline='red', width=3)
|
|
41
|
-
# draw.text(xyxy[:2], label, fill='red')
|
|
42
|
-
|
|
43
|
-
# Save or display image
|
|
44
|
-
# image.save('output/1.jpg')
|
|
45
|
-
# image.show()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
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.35 → ok-script-0.0.37}/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
|
{ok-script-0.0.35/ok/rotypes/Windows/Storage → ok-script-0.0.37/ok/rotypes/Windows}/__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
|