自动化操作脚本

文章目录


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_loc
    return 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 True
    return 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.")
        return

    print("Operation completed successfully.")

if __name__ == "__main__":
    main()

  • 7
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值