控制的前提是已经运行microsip.exe
首先选择文件,
选择txt格式文件,一行一个手机号格式;如下
点击拨打下一个,就会自动输入自动拨打
代码:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
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的资料请关注服务器之家其它相关文章!
原文链接:https://blog.csdn.net/m0_38124502/article/details/117986206