python生成可执行exe控制Microsip自动填写号码并拨打功能

 更新时间:2021年06月21日 15:58:11   作者:我不喜欢这个世界  
这篇文章主要介绍了python生成可执行exe控制Microsip自动填写号码并拨打,在这需要注意一个问题,必须是已经运行Microsip.exe文件,具体实现代码跟随小编一起看看吧

控制的前提是已经运行Microsip.exe

  

首先选择文件,

选择txt格式文件,一行一个手机号格式;如下

点击拨打下一个,就会自动输入自动拨打

代码:

import tkinter
import win32gui
import win32con
from tkinter import filedialog
import tkinter.messagebox
import os
import time
def next_phone(phone):
    win = win32gui.FindWindow('MicroSIP',None)
    tid = win32gui.FindWindowEx(win,None,'#32770',None)
    tid = win32gui.FindWindowEx(tid,None,'ComboBox',None)
    tid = win32gui.FindWindowEx(tid,None,'Edit',None)
    win32gui.SendMessage(tid, win32con.WM_SETTEXT, None, phone)
    win32gui.PostMessage(tid,win32con.WM_KEYDOWN,win32con.VK_RETURN,0)
def openfile():
    sfname = filedialog.askopenfilename(title='选择txt文件', filetypes=[ ('All Files', '*')])
    return sfname
class MicroSIP:
    def __init__(self):
        self.c_window()
 
    def c_window(self):
        self.win = tkinter.Tk()
        self.win.geometry("300x280")
        self.win.resizable(width=False, height=False)
        self.win.protocol('WM_DELETE_WINDOW', self.customized_function)
        self.total = 0
        self.used = 0
        self.res = []
        self.Button1 = tkinter.Button(self.win, text="选择文件", command=self.helloCallBack)
        self.Button_next = tkinter.Button(self.win, text="拨打下一个", command=self.next)
        self.label1 = tkinter.Label(self.win, text="",)
        self.label2 = tkinter.Label(self.win, text="总量:", bg="yellow")
        self.label3 = tkinter.Label(self.win, text="拨打:", bg="red")
        self.label2_2 = tkinter.Label(self.win, text=self.total, )
        self.label3_3 = tkinter.Label(self.win, text=self.used, )
        # label4 = tkinter.Label(win, text="小猪佩奇", bg="green")
        self.Button1.grid(row=0, column=0)
        self.label1.grid(row=0, column=1)
        self.label2.grid(row=2, column=0)
        self.label2_2.grid(row=2, column=1)
        self.label3.grid(row=3, column=0)
        self.label3_3.grid(row=3, column=1)
        self.Button_next.grid(row=5, column=2)
        col_count, row_count = self.win.grid_size()
        for col in range(col_count):
            self.win.grid_columnconfigure(col, minsize=40)
        for row in range(row_count):
            self.win.grid_rowconfigure(row, minsize=40)
        self.win.mainloop()
    def next(self):
        if self.res:
            phone = self.res.pop()
 
            self.used+=1
            self.label3_3['text'] = self.used
            next_phone(phone.strip())
        else:
            res = tkinter.messagebox.showerror(title='文件!', message='选择文件啊!不然打鸡毛!')
    def helloCallBack(self):
        # print("Hello Python", "Hello Runoob")
        file_name = openfile()
        if file_name:
            print(file_name)
            self.label1['text']=file_name.split('/')[-1]
            with open(file_name, 'r', encoding='utf-8')as f:
                self.res = [x.replace('\n', '') for x in f.readlines()]
                self.total = len(self.res)
                self.label2_2['text']=str(len(self.res))
        else:
            res = tkinter.messagebox.showerror(title='文件!', message='选择文件啊!不然打鸡毛!')
    def customized_function(self):
 
        result = tkinter.messagebox.askyesno(title = '离开',message='确定要离开了吗?如没有打完,会把没打完的生成新文件,下次选择新文件就行了!')
        if result:
            if self.total==self.used:
                pass
            else:
                name = time.strftime("%Y_%m_%d_%H_%M_%S_", time.localtime())+"剩余_"+str(self.total-self.used)
                with open(name+'.txt','w',encoding='utf-8')as f:
                    for i in self.res:
                        f.write(i+'\n')
        self.win.destroy()
 
if __name__ == '__main__':
    MicroSIP()

写的比较简单,可以自己优化一下,需要安装pywin32库

打包一下,就可以生成 exe文件  

需要安装pyinstaller 库

命令 pyinstaller -F -w xxx.py

我生成好的exe可供下载:

链接: https://pan.baidu.com/s/1IAx0pgr4ze2jYusisQBXIA

提取码: a3s2

以上就是python生成可执行exe控制Microsip自动填写号码并拨打的详细内容,更多关于python生成可执行exe的资料请关注脚本之家其它相关文章!

相关文章

  • Python实现爆破ZIP文件(支持纯数字,数字+字母,密码本)

    Python实现爆破ZIP文件(支持纯数字,数字+字母,密码本)

    这篇文章主要为大家分享了如何利用Python实现破解zip文件的密码,能实现破解纯数字、数字+字母、密码本等种类的密码,需要的可以参考一下
    2022-03-03
  • Python使用cx_Oracle模块操作Oracle数据库详解

    Python使用cx_Oracle模块操作Oracle数据库详解

    这篇文章主要介绍了Python使用cx_Oracle模块操作Oracle数据库,结合实例形式较为详细的分析了cx_Oracle模块的下载、安装及针对Oracle数据库的连接、执行SQL语句、存储过程等相关操作技巧,需要的朋友可以参考下
    2018-05-05
  • Anaconda超详细保姆级安装配置教程

    Anaconda超详细保姆级安装配置教程

    这篇文章主要介绍了Anaconda超详细保姆级安装配置教程,本篇教程对于新手很友好强烈推荐,看完这篇文章相信你对如何安装配置Anaconda一定了然于胸,我们一起来看看吧
    2023-03-03
  • Python如何读取MySQL数据库表数据

    Python如何读取MySQL数据库表数据

    这篇文章主要为大家详细介绍了Python如何读取MySQL数据库表数据,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2017-03-03
  • 教你用Python创建微信聊天机器人

    教你用Python创建微信聊天机器人

    这篇文章主要手把手教你用Python创建微信聊天机器人,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2018-03-03
  • python关闭windows进程的方法

    python关闭windows进程的方法

    这篇文章主要介绍了python关闭windows进程的方法,涉及Python调用系统命令操作windows进程的技巧,需要的朋友可以参考下
    2015-04-04
  • python中的decorator的作用详解

    python中的decorator的作用详解

    这篇文章主要介绍了python中的decorator的作用详解,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
    2018-07-07
  • tensorflow/core/platform/cpu_feature_guard.cc:140] Your CPU supports instructions that this T

    tensorflow/core/platform/cpu_feature_guard.cc:140] Your CPU

    这篇文章主要介绍了tensorflow/core/platform/cpu_feature_guard.cc:140] Your CPU supports instructions that this T的相关知识,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下
    2020-06-06
  • Python报错NameError: name ‘secrets‘ is not defined解决

    Python报错NameError: name ‘secrets‘ is not

    在使用Python进行安全编程时,我们经常需要使用secrets模块来生成安全的随机数,但是却遇到这个问题,本文主要介绍了Python报错NameError: name ‘secrets‘ is not defined解决,感兴趣的可以了解一下
    2024-06-06
  • Python类继承及super()函数使用说明

    Python类继承及super()函数使用说明

    这篇文章主要介绍了Python类继承及super()函数使用说明,具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教
    2022-11-11

最新评论