update
This commit is contained in:
BIN
hik_uptime/__pycache__/__init__.cpython-311.pyc
Normal file
BIN
hik_uptime/__pycache__/__init__.cpython-311.pyc
Normal file
Binary file not shown.
BIN
hik_uptime/__pycache__/custom_exception.cpython-311.pyc
Normal file
BIN
hik_uptime/__pycache__/custom_exception.cpython-311.pyc
Normal file
Binary file not shown.
2
hik_uptime/custom_exception.py
Normal file
2
hik_uptime/custom_exception.py
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
class NoWindowException(Exception):
|
||||||
|
pass
|
@ -1,27 +1,41 @@
|
|||||||
|
import time
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
import pyautogui
|
import pyautogui
|
||||||
import pytesseract
|
import pytesseract
|
||||||
|
import yaml
|
||||||
|
|
||||||
|
from hik_uptime.custom_exception import NoWindowException
|
||||||
|
|
||||||
|
|
||||||
# # ws = pygetwindow.getAllWindows()
|
def read_config():
|
||||||
# # for x in ws:
|
home_dir = Path.home()
|
||||||
# # print(x.title)
|
with open(home_dir / ".config" / "hik-uptime" / "config.yaml", "r", encoding="utf-8") as f:
|
||||||
#
|
config = yaml.safe_load(f)
|
||||||
# wd = pygetwindow.getWindowsWithTitle("PowerShell")
|
return config
|
||||||
# print(wd[0])
|
|
||||||
# wd[0].activate()
|
|
||||||
# wd[0].maximize()
|
|
||||||
# screenshot = pyautogui.screenshot("screenshot.png")
|
|
||||||
# print(screenshot)
|
|
||||||
# print(pytesseract.get_languages())
|
|
||||||
# result = pytesseract.image_to_string(screenshot)
|
|
||||||
# # print(result)
|
|
||||||
|
|
||||||
def get_status():
|
def get_status():
|
||||||
window = pyautogui.getWindowsWithTitle("Mozilla Firefox")
|
# 找到窗口并最大化
|
||||||
|
window = pyautogui.getWindowsWithTitle("设置")
|
||||||
|
if len(window) == 0:
|
||||||
|
raise NoWindowException("No window found")
|
||||||
|
print(window[0])
|
||||||
window = window[0]
|
window = window[0]
|
||||||
window.maximize()
|
window.maximize()
|
||||||
window.activate()
|
window.activate()
|
||||||
|
|
||||||
|
config = read_config()
|
||||||
|
# TODO: 切换到烟感设备列表
|
||||||
|
for pos in config['menus']:
|
||||||
|
time.sleep(1.5)
|
||||||
|
pyautogui.click(pos['x'], pos['y'])
|
||||||
|
|
||||||
|
# TODO: OCR 获取已离线的设备名称数量
|
||||||
|
color = pyautogui.pixel(138, 8)
|
||||||
|
print('#{:02x}{:02x}{:02x}'.format(*color))
|
||||||
|
|
||||||
|
# TODO: 向 /eventRcv 发送模拟订阅报文
|
||||||
# pyautogui.click(900, 140)
|
# pyautogui.click(900, 140)
|
||||||
# clipboard.copy("网络")
|
# clipboard.copy("网络")
|
||||||
# pyautogui.hotkey('ctrl', 'a')
|
# pyautogui.hotkey('ctrl', 'a')
|
||||||
@ -29,7 +43,7 @@ def get_status():
|
|||||||
# pyautogui.press('enter')
|
# pyautogui.press('enter')
|
||||||
# pyautogui.click(x=window.width // 2, y=window.height // 2)
|
# pyautogui.click(x=window.width // 2, y=window.height // 2)
|
||||||
screenshot = pyautogui.screenshot()
|
screenshot = pyautogui.screenshot()
|
||||||
screenshot = screenshot.crop((313, 46, 1118, 79))
|
screenshot = screenshot.crop((464, 412, 1401, 934))
|
||||||
screenshot.save('screenshot.png')
|
screenshot.save('screenshot.png')
|
||||||
result = pytesseract.image_to_string(screenshot)
|
result = pytesseract.image_to_string(screenshot)
|
||||||
print(result)
|
print(result)
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 2.6 KiB |
Reference in New Issue
Block a user