python生成可執(zhí)行exe控制Microsip自動(dòng)填寫號(hào)碼并撥打功能
控制的前提是已經(jīng)運(yùn)行Microsip.exe
首先選擇文件,
選擇txt格式文件,一行一個(gè)手機(jī)號(hào)格式;如下
點(diǎn)擊撥打下一個(gè),就會(huì)自動(dòng)輸入自動(dòng)撥打
代碼:
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="撥打下一個(gè)", 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='選擇文件?。〔蝗淮螂u毛!') def customized_function(self): result = tkinter.messagebox.askyesno(title = '離開',message='確定要離開了嗎?如沒有打完,會(huì)把沒打完的生成新文件,下次選擇新文件就行了!') 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()
寫的比較簡單,可以自己優(yōu)化一下,需要安裝pywin32庫
打包一下,就可以生成 exe文件
需要安裝pyinstaller 庫
命令 pyinstaller -F -w xxx.py
我生成好的exe可供下載:
鏈接: https://pan.baidu.com/s/1IAx0pgr4ze2jYusisQBXIA
提取碼: a3s2
以上就是python生成可執(zhí)行exe控制Microsip自動(dòng)填寫號(hào)碼并撥打的詳細(xì)內(nèi)容,更多關(guān)于python生成可執(zhí)行exe的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!
相關(guān)文章
Python彩色化Linux的命令行終端界面的代碼實(shí)例分享
美化Linux的terminal終端顯示的方法多種多樣,這里我們給出一個(gè)利用Python彩色化Linux的命令行終端界面的代碼實(shí)例分享,包括一個(gè)Linux下簡便執(zhí)行Python程序的方法,需要的朋友可以參考下2016-07-07Python使用win32com實(shí)現(xiàn)的模擬瀏覽器功能示例
這篇文章主要介紹了Python使用win32com實(shí)現(xiàn)的模擬瀏覽器功能,結(jié)合實(shí)例形式分析了Python基于win32com模塊實(shí)現(xiàn)網(wǎng)頁的打開、登陸、加載等功能相關(guān)技巧,需要的朋友可以參考下2017-07-07python 使用cycle構(gòu)造無限循環(huán)迭代器
這篇文章主要介紹了python 使用cycle構(gòu)造無限循環(huán)迭代器的方法,幫助大家更好的理解和學(xué)習(xí)python,感興趣的朋友可以了解下2020-12-12Python調(diào)用win10toast框架實(shí)現(xiàn)定時(shí)調(diào)起系統(tǒng)通知
win10toast是一個(gè)windows通知的出發(fā)框架,使用它可以輕松的調(diào)起系統(tǒng)通知。通過它可以很方便的做一個(gè)定時(shí)通知的功能應(yīng)用。本文將調(diào)用win10toast實(shí)現(xiàn)定時(shí)調(diào)起系統(tǒng)通知功能,需要的可以參考一下2022-01-01pycharm-professional-2020.1下載與激活的教程
這篇文章主要介紹了pycharm-professional-2020.1下載與激活的教程,本文分為安裝和永久激活兩部分內(nèi)容,需要的朋友可以參考下2020-09-09Python實(shí)現(xiàn)對(duì)數(shù)坐標(biāo)系繪制與自定義映射
這篇文章主要為大家學(xué)習(xí)介紹了如何利用Python實(shí)現(xiàn)對(duì)數(shù)坐標(biāo)系繪制與坐標(biāo)自定義映射,文中的示例代碼講解詳細(xì),感興趣的小伙伴可以了解一下2023-08-08Python學(xué)習(xí)之循環(huán)方法詳解
循環(huán)是有著周而復(fù)始的運(yùn)動(dòng)或變化的規(guī)律;在 Python 中,循環(huán)的操作也叫做 遍歷。與現(xiàn)實(shí)中一樣,Python 中也同樣存在著無限循環(huán)的方法與有限循環(huán)的方法。本文將通過示例詳細(xì)講解Python中的循環(huán)方法,需要的可以參考一下2022-03-03