#安装对应依赖包
import pyautogui
import time
from pywinauto.keyboard import send_keys
from selenium.webdriver.common import keys
def get_position(times): # times为需要打印多少次坐标
for i in range(times):
print("当前鼠标的坐标为:",pyautogui.position()) #循环执行pyautogui.position()获取不同位置坐标
time.sleep(2)
def AutoOpen(times):
startPosition = (210,1065) # 设置入口的坐标位置
wlanPosition_1 = (190,980) # WLAN坐标位置1 result status
wlanPosition_2 = (1000,250) # WLAN坐标位置2 下拉框
wlanPosition_3 = (1006,280) # WLAN坐标位置3 全选/取消全选
wlanPosition_4 = (1006,310) # WLAN坐标位置4 要选择的bu
wlanPosition_5 = (370,980) # WLAN坐标位置5 imp status
wlanPosition_6 = (550,980) # WLAN坐标位置6 opl status
wlanPosition_7 = (45,60) # WLAN坐标位置7 文件
wlanPosition_8 = (55,360) # WLAN坐标位置8 导出
wlanPosition_9 = (390,240) # WLAN坐标位置9 导出pdf
wlanPosition_10 = (1700,110) # WLAN坐标位置10另存pdf
wlanPosition_11 = (210,470) # WLAN坐标位置11 输入保存文件名
wlanPosition_12 = (730,560) # WLAN坐标位置12 保存
position = [startPosition,wlanPosition_1,
wlanPosition_2,wlanPosition_3,
wlanPosition_4,wlanPosition_5,
wlanPosition_2,wlanPosition_3,
wlanPosition_4,wlanPosition_6,
wlanPosition_2,wlanPosition_3,
wlanPosition_4,wlanPosition_7,
wlanPosition_8] #将坐标位置的值存储为列表
for i in position:
pyautogui.moveTo(i)
if i==(1000,250):
time.sleep(2)
pyautogui.click(clicks=1)
time.sleep(2)
pyautogui.moveTo(wlanPosition_9) # 鼠标移动至wlanPosition_9坐标
pyautogui.click(clicks=1)
time.sleep(25)
pyautogui.moveTo(wlanPosition_10) # 鼠标移动至wlanPosition_9坐标
pyautogui.click(clicks=1)
time.sleep(2)
pyautogui.moveTo(wlanPosition_11)
send_keys("2WP")
time.sleep(2)
pyautogui.moveTo(wlanPosition_12) #保存
pyautogui.click(clicks=1)
def AutoOpenAN(wlanPosition_2,wlanPosition_4,name,loading):
startPosition = (210,1065) # 设置入口的坐标位置
wlanPosition_1 = (190,980) # WLAN坐标位置1 result status
# wlanPosition_2 = (1000,250) # WLAN坐标位置2 下拉框
# wlanPosition_3 = (1006,280) # WLAN坐标位置3 全选/取消全选
# wlanPosition_4 = (1006,340) # WLAN坐标位置4 要选择的bu
wlanPosition_5 = (370,980) # WLAN坐标位置5 imp status
wlanPosition_6 = (550,980) # WLAN坐标位置6 opl status
wlanPosition_7 = (45,60) # WLAN坐标位置7 文件
wlanPosition_8 = (55,360) # WLAN坐标位置8 导出
wlanPosition_9 = (390,240) # WLAN坐标位置9 导出pdf
wlanPosition_10 = (1700,110) # WLAN坐标位置10另存pdf
wlanPosition_11 = (210,470) # WLAN坐标位置11 输入保存文件名
wlanPosition_12 = (730,560) # WLAN坐标位置12 保存
position = [startPosition,wlanPosition_1,
wlanPosition_2,
wlanPosition_4,wlanPosition_5,
wlanPosition_2,
wlanPosition_4,wlanPosition_6,
wlanPosition_2,
wlanPosition_4,wlanPosition_7,
wlanPosition_8] #将坐标位置的值存储为列表
for i in position:
pyautogui.moveTo(i)
if i==(1000,250):
time.sleep(2)
pyautogui.click(clicks=1)
time.sleep(2)
pyautogui.moveTo(wlanPosition_9) # 鼠标移动至wlanPosition_9坐标
pyautogui.click(clicks=1)
time.sleep(loading)
pyautogui.moveTo(wlanPosition_10) # 鼠标移动至wlanPosition_9坐标
pyautogui.click(clicks=1)
time.sleep(2)
pyautogui.moveTo(wlanPosition_11)
send_keys(name)
time.sleep(2)
pyautogui.moveTo(wlanPosition_12) #保存
pyautogui.click(clicks=1)
def AutoOpenGI(wlanPosition_2,wlanPosition_4,name,loading):
startPosition = (210,1065) # 设置入口的坐标位置
wlanPosition_1 = (190,980) # WLAN坐标位置1 result status
# wlanPosition_2 = (1000,250) # WLAN坐标位置2 下拉框
# wlanPosition_3 = (1006,280) # WLAN坐标位置3 全选/取消全选
# wlanPosition_4 = (1002,400) # WLAN坐标位置4 要选择的bu
wlanPosition_5 = (370,980) # WLAN坐标位置5 imp status
wlanPosition_6 = (550,980) # WLAN坐标位置6 opl status
wlanPosition_7 = (45,60) # WLAN坐标位置7 文件
wlanPosition_8 = (55,360) # WLAN坐标位置8 导出
wlanPosition_9 = (390,240) # WLAN坐标位置9 导出pdf
wlanPosition_10 = (1700,110) # WLAN坐标位置10另存pdf
wlanPosition_11 = (210,470) # WLAN坐标位置11 输入保存文件名
wlanPosition_12 = (730,560) # WLAN坐标位置12 保存
position = [startPosition,wlanPosition_1,
wlanPosition_2,
wlanPosition_4,wlanPosition_5,
wlanPosition_2,
wlanPosition_4,wlanPosition_6,
wlanPosition_2,
wlanPosition_4,wlanPosition_7,
wlanPosition_8] #将坐标位置的值存储为列表
for i in position:
pyautogui.moveTo(i)
if i==wlanPosition_4:
pyautogui.scroll(-280)
time.sleep(2)
pyautogui.click(clicks=1)
time.sleep(2)
pyautogui.moveTo(wlanPosition_9) # 鼠标移动至wlanPosition_9坐标
pyautogui.click(clicks=1)
time.sleep(loading)
pyautogui.moveTo(wlanPosition_10) # 鼠标移动至wlanPosition_9坐标
pyautogui.click(clicks=1)
time.sleep(2)
pyautogui.moveTo(wlanPosition_11)
send_keys(name)
time.sleep(2)
pyautogui.moveTo(wlanPosition_12) #保存
pyautogui.click(clicks=1)
if __name__ == '__main__':
# get_position(3) #调用获取鼠标坐标的方法,确认对应坐标后则可不调用该方法
AutoOpen(4) #调用打开关闭WiFi的方法,4为点击开关的次
time.sleep(3)
AutoOpenAN((1000,250),(1006,340),"AN",25) #
time.sleep(3)
AutoOpenAN((1000,250),(1006,370),"CC",25) #
time.sleep(3)
AutoOpenAN((1000,250),(1006,400),"EC",25) #
time.sleep(3)
AutoOpenAN((1000,250),(1006,430),"EH-PD1",25) #
time.sleep(3)
AutoOpenAN((1000,250),(1006,450),"EH-PD2",30) #
time.sleep(3)
AutoOpenGI((1000,250),(1002,400),"GI",30) #
time.sleep(3)
AutoOpenGI((1000,250),(1002,430),"SI",30) #
time.sleep(3)
AutoOpenGI((1000,250),(1002,450),"TC",30) #
网友评论