#python模拟实现自动填写网页表单源码 运行:Python3+第三方包
# coding: utf-8
import time,sys
import pyautogui,pyperclip
import pandas as pd
#保护措施,避免失控
pyautogui.FAILSAFE = False
#为所有的PyAutoGUI函数增加延迟。默认延迟时间是0.1秒。
pyautogui.PAUSE = 0.6
#1366X768 IDLE最大化时 进行最小化IDLE
pyautogui.click(x=1264, y=17, clicks=1, interval=0.0, button='left', duration=0.5, tween=pyautogui.linear)
pyautogui.click(x=1264, y=17, clicks=1, interval=0.0, button='left', duration=0.5, tween=pyautogui.linear)
df=pd.read_excel('info1.xlsx',sheet_name=0)
time.sleep(2)
for i in range(df.shape[0]):
Hangdata=df.iloc[i].tolist() #用列表操作 其实Series也可以操作
a=Hangdata[0] #单号
b=Hangdata[1] #小区级_filename
c=Hangdata[2] #分析-WD_filename
pyautogui.click(x=762, y=200, clicks=2, interval=0.0, button='left', duration=0.5, tween=pyautogui.linear) #工单号查询
time.sleep(0.2)
pyperclip.copy(a)
pyautogui.hotkey('ctrl','a')
pyautogui.hotkey('ctrl','v')
#查询按钮
pyautogui.doubleClick(x=1249, y=199, interval=0.0, button='left', duration=0.2, tween=pyautogui.linear)
time.sleep(8)
#进入工单
pyautogui.doubleClick(x=549, y=299, interval=0.0, button='left', duration=0.5, tween=pyautogui.linear)
time.sleep(14)
#下拉(1)
pyautogui.click(x=1342, y=671, clicks=3, interval=0.2, button='left', duration=0.8, tween=pyautogui.linear)
time.sleep(0.2)
#选择类型
pyautogui.click(x=547, y=578, clicks=2, interval=0.0, button='left', duration=0.8, tween=pyautogui.linear)
pyautogui.click(162,424,duration=0.5)
time.sleep(3)
#选择是否现场测试
pyautogui.click(x=1260, y=576, clicks=2, interval=0.1, button='left', duration=1, tween=pyautogui.linear)
pyautogui.click(1260,643,duration=0.5)
time.sleep(1)
#选择是否疑难问题
pyautogui.click(x=547, y=606, clicks=2, interval=0.0, button='left', duration=0.8, tween=pyautogui.linear)
pyautogui.click(547,671,duration=0.5)
time.sleep(1)
#选择处理方案
pyautogui.click(x=1201, y=605, clicks=2, interval=0.0, button='left', duration=0.8, tween=pyautogui.linear)
pyautogui.click(1201,495,duration=0.5)
time.sleep(1)
#选择小区级
pyautogui.click(x=547, y=638, clicks=1, interval=0.0, button='left', duration=0.8, tween=pyautogui.linear)
pyautogui.click(x=162, y=441, clicks=1, interval=0.0, button='left', duration=0.8, tween=pyautogui.linear)
pyautogui.click(x=297, y=613, clicks=1, interval=0.0, button='left', duration=0.8, tween=pyautogui.linear)
time.sleep(1)
#再次下拉(2)
pyautogui.click(x=1342, y=671, clicks=3, interval=0.2, button='left', duration=0.8, tween=pyautogui.linear)
time.sleep(2)
#EXCEL导入
pyautogui.click(x=1172, y=353, clicks=2, interval=0.1, button='left', duration=0.8, tween=pyautogui.linear) #EXCEL导入
pyautogui.click(x=1017, y=354, clicks=2, interval=0.1, button='left', duration=0.8, tween=pyautogui.linear) #浏览
time.sleep(0.2)
pyautogui.click(x=52, y=282, clicks=1, interval=0.0, button='left', duration=0.8, tween=pyautogui.linear) #我的电脑
time.sleep(0.2)
pyautogui.click(x=241, y=325, clicks=2, interval=0.0, button='left', duration=0.8, tween=pyautogui.linear) #H盘
time.sleep(0.2)
pyautogui.click(x=202, y=227, clicks=2, interval=0.0, button='left', duration=0.8, tween=pyautogui.linear) #工单目录
time.sleep(0.2)
pyautogui.click(x=183, y=143, clicks=2, interval=0.0, button='left', duration=0.8, tween=pyautogui.linear) #小区级目录
time.sleep(0.2)
#文件夹查找小区级excel
pyperclip.copy(b)
time.sleep(0.2)
pyautogui.click(x=282, y=661, clicks=2, interval=0.0, button='left', duration=0.8, tween=pyautogui.linear)
pyautogui.hotkey('ctrl','v')
time.sleep(0.2)
pyautogui.click(1305,660,duration=0.5)
pyautogui.click(924,666,duration=0.5)
time.sleep(0.5)
pyautogui.click(924,666,duration=0.5)
time.sleep(12)
pyautogui.click(924,666,duration=0.5)
time.sleep(8)
pyautogui.click(926,669,duration=0.5)
#上传分析WD文件
pyautogui.click(x=651, y=634, clicks=1, interval=0.0, button='left', duration=0.8, tween=pyautogui.linear) #措施
pyautogui.click(x=477, y=397, clicks=1, interval=0.0, button='left', duration=0.5, tween=pyautogui.linear) #添加
pyautogui.click(x=416, y=50, clicks=1, interval=0.0, button='left', duration=0.5, tween=pyautogui.linear) #返回上一级目录
pyautogui.click(x=223, y=122, clicks=2, interval=0.0, button='left', duration=0.8, tween=pyautogui.linear) #选择分析WD文件夹
time.sleep(1)
pyautogui.click(x=997, y=659, clicks=2, interval=0.1, button='left', duration=1, tween=pyautogui.linear) #粘贴名字
pyperclip.copy(c)
pyautogui.hotkey('ctrl','v')
time.sleep(0.2)
pyautogui.click(x=1308, y=661, clicks=1, interval=0.0, button='left', duration=0.8, tween=pyautogui.linear) #打开按钮
time.sleep(4)
pyautogui.click(x=786, y=581, clicks=2, interval=0.1, button='left', duration=0.8, tween=pyautogui.linear) #确认上传docx
#pyautogui.click(x=1242, y=708, clicks=2, interval=0.0, button='left', duration=0.8, tween=pyautogui.linear) #保存测试
pyautogui.click(x=1317, y=708, clicks=2, interval=0.05, button='left', duration=1.2, tween=pyautogui.linear) #提交
time.sleep(28)
pyautogui.click(x=819, y=496, clicks=2, interval=0.1, button='left', duration=0.8, tween=pyautogui.linear) #确认
time.sleep(3)
print("已完成!")
发表评论