python自动化脚本-简化留言

本文通过编写python自动化脚本,实现了简单的单击按钮将不同中英文内容写入网页的特定位置。

以呼叫系统为例,呼叫人员需要根据不同的场景选择不同的留言模板进行留言。一般的操作是将所有的留言模板配置在文本文件中,使用的时候将对应的留言模板复制粘贴到特定的位置,修改后进行提交。在呼叫高峰期的时候,特别容易出错,导致客诉增加。

本文通过python,编写自动化留言脚本,将操作简化,提高效率,降低出错率。

通过分析,可将留言分为两大类,一人多单或一人一单;留言主要集中在预约成功,未接通,一天三呼,七天一呼,改期等这几个常用部分。

设计界面如下:

界面代码如下:

python 复制代码
root = tk.Tk()
root.title(r"自动留言")

root.attributes("-topmost", True)

var_more = tk.IntVar()
checkbox = tk.Checkbutton(root, text="一人多单", variable=var_more)
checkbox.pack(pady=10)

button = tk.Button(root, text=r"预约成功", command=me_suc)
button.config(bg='green')
button.pack(pady=10)

button = tk.Button(root, text=r"未接通", command=me_fail_1)
button.config(bg='red')
button.pack(pady=10)

button = tk.Button(root, text=r"三呼改走", command=me_fail_2)
button.config(bg='red')
button.pack(pady=10)

button = tk.Button(root, text=r"七天改走", command=me_fail_3)
button.config(bg='red')
button.pack(pady=10)

button = tk.Button(root, text=r"改期", command=me_fail_4)
button.config(bg='red')
button.pack(pady=10)

root.mainloop()

点击按钮代码如下:

python 复制代码
def me_suc():
    me_more = ''
    if var_more.get() == 1:
        me_more = '一人多单, 在123456外呼, '
    cur_day = time.strftime('%m月%d日', time.localtime())
    me = cur_day + r'和客户进行预约' + cur_day+ r'配送, ' + me_more + r'快速沟通解决, 咚咚org.sqdyyykf1'
    clip_copy(me)

文本写入网页代码如下:

python 复制代码
def clip_copy(txt):
    # 复制内容到剪贴板
    pyperclip.copy(txt)
    # 写入的位置(380,910)
    pyautogui.moveTo(x=380, y=910)
    pyautogui.click(x=380, y=910)
    time.sleep(0.5)
    pyautogui.hotkey('ctrl', 'a')
    time.sleep(0.5)
    pyautogui.hotkey('ctrl', 'v')

完整代码如下:

python 复制代码
import tkinter as tk
import pyperclip
import time
import pyautogui

def clip_copy(txt):
    # 复制内容到剪贴板
    pyperclip.copy(txt)
    # 写入的位置(380,910)
    pyautogui.moveTo(x=380, y=910)
    pyautogui.click(x=380, y=910)
    time.sleep(0.5)
    pyautogui.hotkey('ctrl', 'a')
    time.sleep(0.5)
    pyautogui.hotkey('ctrl', 'v')

def me_suc():
    me_more = ''
    if var_more.get() == 1:
        me_more = '一人多单, 在123456外呼, '
    cur_day = time.strftime('%m月%d日', time.localtime())
    me = cur_day + r'和客户进行预约' + cur_day+ r'配送, ' + me_more + r'快速沟通解决, 咚咚org.sqdyyykf1'
    clip_copy(me)

def me_fail_1():
    me_more = ''
    if var_more.get() == 1:
        me_more = '一人多单, 在123456外呼, '
    cur_day = time.strftime('%m月%d日', time.localtime())
    me = cur_day + r'和客户进行预约, 未预约成功的原因为(未接通), ' + me_more + r'快速沟通解决, 咚咚org.sqdyyykf1'
    clip_copy(me)

def me_fail_2():
    me_more = ''
    if var_more.get() == 1:
        me_more = '一人多单, 在123456外呼, '
    cur_day = time.strftime('%m月%d日', time.localtime())
    me = cur_day+ r'和客户进行预约, 未预约成功的原因为(截单点【外呼三次】未接通, 延后一天), ' + me_more + r'快速沟通解决, 咚咚org.sqdyyykf1'
    clip_copy(me)

def me_fail_3():
    me_more = ''
    if var_more.get() == 1:
        me_more = '一人多单, 在123456外呼, '
    cur_day = time.strftime('%m月%d日', time.localtime())
    me = cur_day + r'和客户进行预约, 未预约成功的原因为(已连续3天未接通【7天联系一次】), ' + me_more + r'快速沟通解决, 咚咚org.sqdyyykf1'
    clip_copy(me)

def me_fail_4():
    me_more = ''
    if var_more.get() == 1:
        me_more = '一人多单, 在123456外呼, '
    cur_day = time.strftime('%m月%d日', time.localtime())
    me = cur_day + r'和客户进行预约, 未预约成功的原因为(改期至' + cur_day + r'),  ' + me_more + r'快速沟通解决, 咚咚org.sqdyyykf1'
    clip_copy(me)

root = tk.Tk()
root.title(r"自动留言")

root.attributes("-topmost", True)

var_more = tk.IntVar()
checkbox = tk.Checkbutton(root, text="一人多单", variable=var_more)
checkbox.pack(pady=10)

button = tk.Button(root, text=r"预约成功", command=me_suc)
button.config(bg='green')
button.pack(pady=10)

button = tk.Button(root, text=r"未接通", command=me_fail_1)
button.config(bg='red')
button.pack(pady=10)

button = tk.Button(root, text=r"三呼改走", command=me_fail_2)
button.config(bg='red')
button.pack(pady=10)

button = tk.Button(root, text=r"七天改走", command=me_fail_3)
button.config(bg='red')
button.pack(pady=10)

button = tk.Button(root, text=r"改期", command=me_fail_4)
button.config(bg='red')
button.pack(pady=10)

root.mainloop()

运行效果如下:

相关推荐
玄同7658 小时前
Python Random 模块深度解析:从基础 API 到 AI / 大模型工程化实践
人工智能·笔记·python·学习·算法·语言模型·llm
风指引着方向8 小时前
昇腾 AI 开发生产力工具:CANN CLI 的高级使用与自动化脚本编写
运维·人工智能·自动化
掌心向暖RPA自动化8 小时前
影刀RPA如何在网页和桌面软件中实现自动滚动长截图?最好同时支持横向滚动纵向滚动的?
经验分享·自动化·影刀rpa·长截图
AIFarmer8 小时前
在EV3上运行Python语言——环境设置
python·ev3
yunsr9 小时前
python作业3
开发语言·python
历程里程碑9 小时前
普通数组-----除了自身以外数组的乘积
大数据·javascript·python·算法·elasticsearch·搜索引擎·flask
曦月逸霜9 小时前
Python快速入门——学习笔记(持续更新中~)
笔记·python·学习
淡忘_cx9 小时前
使用Jenkins自动化部署spring-java项目+宝塔重启项目命令(2.528.2版本)
java·自动化·jenkins
喵手9 小时前
Python爬虫实战:采集菜谱网站的“分类/列表页”(例如“家常菜”或“烘焙”频道)数据,构建高可用的美食菜谱数据采集流水线(附CSV导出)!
爬虫·python·爬虫实战·零基础python爬虫教学·采集菜谱网站数据·家常菜或烘焙频道·构建高可用食谱数据采集系统
喵手9 小时前
Python爬虫实战:硬核解析 Google Chrome 官方更新日志(正则+文本清洗篇)(附 CSV 导出)!
爬虫·python·爬虫实战·零基础python爬虫教学·csv导出·监控谷歌版本发布历史·获取稳定版更新日志