文章目錄
- vbs
- openCV + pyautogui
vbs
SSH連接并執行指令操作
Dim WshShell
Set WshShell=WScript.CreateObject("WScript.Shell") WshShell.Run "cmd.exe"
WScript.Sleep 1000
WshShell.SendKeys "ssh xcmg@10.27.40.103"
WshShell.SendKeys "{ENTER}"
WScript.Sleep 1000
WshShell.SendKeys "123"
WshShell.SendKeys "{ENTER}"
WshShell.SendKeys "cd agv_1 && xmake run"
WshShell.SendKeys "{ENTER}"
MQTT服務器啟動
Dim WshShell
Set WshShell=WScript.CreateObject("WScript.Shell") WshShell.Run "cmd.exe"
WScript.Sleep 1000
WshShell.SendKeys "C:\Users\USER\emqx-5.3.0-windows-amd64\bin\emqx start"
WshShell.SendKeys "{ENTER}"
Dim WshShell
Set WshShell=WScript.CreateObject("WScript.Shell") WshShell.Run "cmd.exe"
WScript.Sleep 1000
WshShell.SendKeys "D:"
WshShell.SendKeys "{ENTER}"
WshShell.SendKeys "cd D:\Program Files {(}x86{)}\work\emqx\bin"
WshShell.SendKeys "{ENTER}"
WshShell.SendKeys "emqx start"
WshShell.SendKeys "{ENTER}"
openCV + pyautogui
import cv2
import numpy as np
import pyautogui
import time# 捕獲屏幕的函數
def capture_screen():image = pyautogui.screenshot()image = cv2.cvtColor(np.array(image), cv2.COLOR_RGB2BGR)return image# 尋找目標圖像的函數
def find_target(screen, target, threshold=0.8):result = cv2.matchTemplate(screen, target, cv2.TM_CCOEFF_NORMED)_, max_val, _, max_loc = cv2.minMaxLoc(result)if max_val > threshold:return max_locreturn None# 點擊目標的函數
def click_target(target_image_path, waiting_time=5):# 等待程序加載或窗口出現time.sleep(waiting_time)target_image = cv2.imread(target_image_path)screen = capture_screen()target_location = find_target(screen, target_image)if target_location:# 計算圖標的中心位置并點擊target_center = (target_location[0] + target_image.shape[1]//2, target_location[1] + target_image.shape[0]//2)pyautogui.click(target_center)return Truereturn False# 主函數
def main():# 點擊與軟件鏈接的文件if not click_target('path_to_file_icon.jpg'):print("Failed to find the file icon.")return# 等待軟件啟動并點擊軟件界面中的按鈕if not click_target('path_to_software_button.jpg', waiting_time=10):print("Failed to find the button in the software.")return# 點擊新窗口中的按鈕if not click_target('path_to_new_window_button.jpg', waiting_time=5):print("Failed to find the button in the new window.")returnprint("Operation completed successfully.")if __name__ == "__main__":main()