kotonebot 0.4.0__py3-none-any.whl → 0.5.0__py3-none-any.whl
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.
- kotonebot/__init__.py +39 -39
- kotonebot/backend/bot.py +312 -312
- kotonebot/backend/color.py +525 -525
- kotonebot/backend/context/__init__.py +3 -3
- kotonebot/backend/context/task_action.py +183 -183
- kotonebot/backend/core.py +129 -129
- kotonebot/backend/debug/entry.py +89 -89
- kotonebot/backend/debug/mock.py +78 -78
- kotonebot/backend/debug/server.py +222 -222
- kotonebot/backend/debug/vars.py +351 -351
- kotonebot/backend/dispatch.py +227 -227
- kotonebot/backend/flow_controller.py +196 -196
- kotonebot/backend/ocr.py +535 -529
- kotonebot/backend/preprocessor.py +103 -103
- kotonebot/client/__init__.py +9 -9
- kotonebot/client/device.py +528 -503
- kotonebot/client/fast_screenshot.py +377 -377
- kotonebot/client/host/__init__.py +43 -12
- kotonebot/client/host/adb_common.py +107 -103
- kotonebot/client/host/custom.py +118 -114
- kotonebot/client/host/leidian_host.py +196 -201
- kotonebot/client/host/mumu12_host.py +353 -358
- kotonebot/client/host/protocol.py +214 -213
- kotonebot/client/host/windows_common.py +58 -58
- kotonebot/client/implements/__init__.py +71 -15
- kotonebot/client/implements/adb.py +89 -85
- kotonebot/client/implements/adb_raw.py +162 -158
- kotonebot/client/implements/nemu_ipc/__init__.py +11 -7
- kotonebot/client/implements/nemu_ipc/external_renderer_ipc.py +284 -284
- kotonebot/client/implements/nemu_ipc/nemu_ipc.py +327 -327
- kotonebot/client/implements/remote_windows.py +188 -188
- kotonebot/client/implements/uiautomator2.py +85 -81
- kotonebot/client/implements/windows.py +176 -172
- kotonebot/client/protocol.py +69 -69
- kotonebot/client/registration.py +24 -24
- kotonebot/config/base_config.py +96 -96
- kotonebot/config/manager.py +36 -36
- kotonebot/errors.py +76 -71
- kotonebot/interop/win/__init__.py +10 -3
- kotonebot/interop/win/_mouse.py +311 -0
- kotonebot/interop/win/message_box.py +313 -313
- kotonebot/interop/win/reg.py +37 -37
- kotonebot/interop/win/shortcut.py +43 -43
- kotonebot/interop/win/task_dialog.py +513 -513
- kotonebot/logging/__init__.py +2 -2
- kotonebot/logging/log.py +17 -17
- kotonebot/primitives/__init__.py +17 -17
- kotonebot/primitives/geometry.py +862 -290
- kotonebot/primitives/visual.py +63 -63
- kotonebot/tools/mirror.py +354 -354
- kotonebot/ui/file_host/sensio.py +36 -36
- kotonebot/ui/file_host/tmp_send.py +54 -54
- kotonebot/ui/pushkit/__init__.py +3 -3
- kotonebot/ui/pushkit/image_host.py +88 -87
- kotonebot/ui/pushkit/protocol.py +13 -13
- kotonebot/ui/pushkit/wxpusher.py +54 -53
- kotonebot/ui/user.py +148 -148
- kotonebot/util.py +436 -436
- {kotonebot-0.4.0.dist-info → kotonebot-0.5.0.dist-info}/METADATA +82 -81
- kotonebot-0.5.0.dist-info/RECORD +71 -0
- {kotonebot-0.4.0.dist-info → kotonebot-0.5.0.dist-info}/licenses/LICENSE +673 -673
- kotonebot-0.4.0.dist-info/RECORD +0 -70
- {kotonebot-0.4.0.dist-info → kotonebot-0.5.0.dist-info}/WHEEL +0 -0
- {kotonebot-0.4.0.dist-info → kotonebot-0.5.0.dist-info}/top_level.txt +0 -0
kotonebot/interop/win/reg.py
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
import winreg
|
|
2
|
-
from typing import Any, Literal
|
|
3
|
-
|
|
4
|
-
RegKey = Literal["HKLM", "HKCU", "HKCR", "HKU", "HKCC"]
|
|
5
|
-
|
|
6
|
-
def read_reg(key: RegKey, subkey: str, name: str, *, default: Any = None) -> Any:
|
|
7
|
-
"""
|
|
8
|
-
读取注册表项的值。
|
|
9
|
-
|
|
10
|
-
:param key: 注册表键,例如 "HKLM" (HKEY_LOCAL_MACHINE), "HKCU" (HKEY_CURRENT_USER) 等。
|
|
11
|
-
:param subkey: 注册表子键的路径。
|
|
12
|
-
:param name: 要读取的值的名称。
|
|
13
|
-
:param default: 如果注册表项不存在时返回的默认值。
|
|
14
|
-
:return: 注册表项的值,如果不存在则返回默认值。
|
|
15
|
-
"""
|
|
16
|
-
try:
|
|
17
|
-
hkey = {
|
|
18
|
-
"HKLM": winreg.HKEY_LOCAL_MACHINE,
|
|
19
|
-
"HKCU": winreg.HKEY_CURRENT_USER,
|
|
20
|
-
"HKCR": winreg.HKEY_CLASSES_ROOT,
|
|
21
|
-
"HKU": winreg.HKEY_USERS,
|
|
22
|
-
"HKCC": winreg.HKEY_CURRENT_CONFIG,
|
|
23
|
-
}[key]
|
|
24
|
-
except KeyError:
|
|
25
|
-
raise ValueError(f"Invalid key: {key}")
|
|
26
|
-
|
|
27
|
-
try:
|
|
28
|
-
with winreg.OpenKey(hkey, subkey) as key_handle:
|
|
29
|
-
value, _ = winreg.QueryValueEx(key_handle, name)
|
|
30
|
-
return value
|
|
31
|
-
except FileNotFoundError:
|
|
32
|
-
return default
|
|
33
|
-
except OSError as e:
|
|
34
|
-
if e.winerror == 2: # 注册表项不存在
|
|
35
|
-
return default
|
|
36
|
-
else:
|
|
37
|
-
raise # 其他 OSError 异常,例如权限问题,重新抛出
|
|
1
|
+
import winreg
|
|
2
|
+
from typing import Any, Literal
|
|
3
|
+
|
|
4
|
+
RegKey = Literal["HKLM", "HKCU", "HKCR", "HKU", "HKCC"]
|
|
5
|
+
|
|
6
|
+
def read_reg(key: RegKey, subkey: str, name: str, *, default: Any = None) -> Any:
|
|
7
|
+
"""
|
|
8
|
+
读取注册表项的值。
|
|
9
|
+
|
|
10
|
+
:param key: 注册表键,例如 "HKLM" (HKEY_LOCAL_MACHINE), "HKCU" (HKEY_CURRENT_USER) 等。
|
|
11
|
+
:param subkey: 注册表子键的路径。
|
|
12
|
+
:param name: 要读取的值的名称。
|
|
13
|
+
:param default: 如果注册表项不存在时返回的默认值。
|
|
14
|
+
:return: 注册表项的值,如果不存在则返回默认值。
|
|
15
|
+
"""
|
|
16
|
+
try:
|
|
17
|
+
hkey = {
|
|
18
|
+
"HKLM": winreg.HKEY_LOCAL_MACHINE,
|
|
19
|
+
"HKCU": winreg.HKEY_CURRENT_USER,
|
|
20
|
+
"HKCR": winreg.HKEY_CLASSES_ROOT,
|
|
21
|
+
"HKU": winreg.HKEY_USERS,
|
|
22
|
+
"HKCC": winreg.HKEY_CURRENT_CONFIG,
|
|
23
|
+
}[key]
|
|
24
|
+
except KeyError:
|
|
25
|
+
raise ValueError(f"Invalid key: {key}")
|
|
26
|
+
|
|
27
|
+
try:
|
|
28
|
+
with winreg.OpenKey(hkey, subkey) as key_handle:
|
|
29
|
+
value, _ = winreg.QueryValueEx(key_handle, name)
|
|
30
|
+
return value
|
|
31
|
+
except FileNotFoundError:
|
|
32
|
+
return default
|
|
33
|
+
except OSError as e:
|
|
34
|
+
if e.winerror == 2: # 注册表项不存在
|
|
35
|
+
return default
|
|
36
|
+
else:
|
|
37
|
+
raise # 其他 OSError 异常,例如权限问题,重新抛出
|
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
import os
|
|
2
|
-
import typing
|
|
3
|
-
|
|
4
|
-
import pythoncom
|
|
5
|
-
from win32comext.shell import shell, shellcon
|
|
6
|
-
|
|
7
|
-
def create_shortcut(target_file: str, target_args: str, link_file: str | None, *,
|
|
8
|
-
link_name: str | None = None,
|
|
9
|
-
icon_path: str, description: str = ""):
|
|
10
|
-
"""
|
|
11
|
-
Creates a shortcut.
|
|
12
|
-
|
|
13
|
-
:param target_file: The path to the target file.
|
|
14
|
-
:param target_args: The arguments for the target file.
|
|
15
|
-
:param link_file: The path to the shortcut file. If None, creates on the desktop.
|
|
16
|
-
:param link_name: The name of the shortcut file. If None, it is derived from the target file name.
|
|
17
|
-
Only used when link_file is None.
|
|
18
|
-
:param icon_path: The path to the icon file.
|
|
19
|
-
:param description: The description of the shortcut.
|
|
20
|
-
"""
|
|
21
|
-
pythoncom.CoInitialize()
|
|
22
|
-
if link_file is None:
|
|
23
|
-
desktop_path = shell.SHGetFolderPath(0, shellcon.CSIDL_DESKTOP, 0, 0)
|
|
24
|
-
if link_name is None:
|
|
25
|
-
link_name = os.path.splitext(os.path.basename(target_file))[0]
|
|
26
|
-
link_file = os.path.join(desktop_path, f"{link_name}.lnk")
|
|
27
|
-
|
|
28
|
-
shortcut = pythoncom.CoCreateInstance(
|
|
29
|
-
shell.CLSID_ShellLink,
|
|
30
|
-
None,
|
|
31
|
-
pythoncom.CLSCTX_INPROC_SERVER,
|
|
32
|
-
shell.IID_IShellLink
|
|
33
|
-
)
|
|
34
|
-
# TODO: 下面这些方法都没有 typing,会报错,需要一种方法加入 typing
|
|
35
|
-
shortcut.SetPath(target_file) # type: ignore
|
|
36
|
-
shortcut.SetArguments(target_args) # type: ignore
|
|
37
|
-
shortcut.SetDescription(description) # type: ignore
|
|
38
|
-
shortcut.SetIconLocation(icon_path, 0) # type: ignore
|
|
39
|
-
|
|
40
|
-
persist_file = shortcut.QueryInterface(pythoncom.IID_IPersistFile)
|
|
41
|
-
persist_file.Save(link_file, 0) # type: ignore
|
|
42
|
-
pythoncom.CoUninitialize()
|
|
43
|
-
|
|
1
|
+
import os
|
|
2
|
+
import typing
|
|
3
|
+
|
|
4
|
+
import pythoncom
|
|
5
|
+
from win32comext.shell import shell, shellcon
|
|
6
|
+
|
|
7
|
+
def create_shortcut(target_file: str, target_args: str, link_file: str | None, *,
|
|
8
|
+
link_name: str | None = None,
|
|
9
|
+
icon_path: str, description: str = ""):
|
|
10
|
+
"""
|
|
11
|
+
Creates a shortcut.
|
|
12
|
+
|
|
13
|
+
:param target_file: The path to the target file.
|
|
14
|
+
:param target_args: The arguments for the target file.
|
|
15
|
+
:param link_file: The path to the shortcut file. If None, creates on the desktop.
|
|
16
|
+
:param link_name: The name of the shortcut file. If None, it is derived from the target file name.
|
|
17
|
+
Only used when link_file is None.
|
|
18
|
+
:param icon_path: The path to the icon file.
|
|
19
|
+
:param description: The description of the shortcut.
|
|
20
|
+
"""
|
|
21
|
+
pythoncom.CoInitialize()
|
|
22
|
+
if link_file is None:
|
|
23
|
+
desktop_path = shell.SHGetFolderPath(0, shellcon.CSIDL_DESKTOP, 0, 0)
|
|
24
|
+
if link_name is None:
|
|
25
|
+
link_name = os.path.splitext(os.path.basename(target_file))[0]
|
|
26
|
+
link_file = os.path.join(desktop_path, f"{link_name}.lnk")
|
|
27
|
+
|
|
28
|
+
shortcut = pythoncom.CoCreateInstance(
|
|
29
|
+
shell.CLSID_ShellLink,
|
|
30
|
+
None,
|
|
31
|
+
pythoncom.CLSCTX_INPROC_SERVER,
|
|
32
|
+
shell.IID_IShellLink
|
|
33
|
+
)
|
|
34
|
+
# TODO: 下面这些方法都没有 typing,会报错,需要一种方法加入 typing
|
|
35
|
+
shortcut.SetPath(target_file) # type: ignore
|
|
36
|
+
shortcut.SetArguments(target_args) # type: ignore
|
|
37
|
+
shortcut.SetDescription(description) # type: ignore
|
|
38
|
+
shortcut.SetIconLocation(icon_path, 0) # type: ignore
|
|
39
|
+
|
|
40
|
+
persist_file = shortcut.QueryInterface(pythoncom.IID_IPersistFile)
|
|
41
|
+
persist_file.Save(link_file, 0) # type: ignore
|
|
42
|
+
pythoncom.CoUninitialize()
|
|
43
|
+
|