python自动化:uiautomation、pyautogui操作会计记账系统(1)处理收支明细表

#coding=utf-8
#,收支明细表,收益及支出明细表 [会计] statement of income and expenditure,导出的表格包含明细或不包含明细。
import xlrd, xlwt, pyautogui, pyperclip, openpyxl,pandas,os, tkinter,\datetime, win32gui, uiautomation, subprocess, xlwings,json,easygui, re
from tkinter.filedialog import askopenfilename
import time
import ctypes
import ctypes.wintypes
pyautogui.PAUSE = 1
mont_list =['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月']
year_input = easygui.integerbox(msg='请输入年份', lowerbound=2005, upperbound=2050)
mont_input = easygui.integerbox(msg='请输入月份', lowerbound=1, upperbound=12)
# ccbox() 提供一个选择:Continue 或者 Cancel,并相应的返回 1(选中Continue)或者 0(选中Cancel)。注意 ccbox() 是返回整型的 1 或 0,不是布尔类型的 True 或 False。
# detailed or not
# deta_or_not = easygui.ccbox(msg='导出的收支明细表是否包含明细?', title='请选择', choices=('是    ', '    否'), image=None)
deta_or_not = easygui.buttonbox(msg="导出的收支明细表是否包含明细?", title="",choices=("                是                ", "                否                "))
#print(deta_or_not)
#print(type(deta_or_not))msg = '浏览需要导出的村委会Excel表格文件并打开'
title = '打开文件'
default = 'E:\MyProjects\PycharmProjects\python01\AutoFillBeijiaAccounting\选择导出数据的经联社、经济社用\**电脑端账套号 所有经济组织按账套号排序 17个经联社.xlsx'
filePath = easygui.fileopenbox(msg=msg, title= title, default= default)
#print(filePath)
df = pandas.read_excel(filePath)
#df = pd.read_excel(src_file, header=1, usecols='B:F')
#header参数为一个整数,从0开始索引,其为选择的行,比如1表示Excel中的第2行。
#usecols参数设定选择的Excel列范围范围(A-…),例如,B:F表示读取B到F列。accnt_dict=dict(zip(df['账套号'],df['账套号加单位简称']))print('获取字典的键,要转化为列表。第一个键是:',end='')account_Num= list(accnt_dict)[0]
print(account_Num)
print('桌面不能打开其他程序,程序在左下角运行。程序运行时不能操作鼠标和键盘,不能打开word和WPS。文件保存在D:\**会计系统导出数据.')
#pyautogui.alert(text="桌面不能打开其他程序,程序在左下角运行。程序运行时不能操作鼠标和键盘。文件保存在D:\**会计系统导出数据",title="提示")
time.sleep(1)#time.sleep(20)#打开程序
proc_list = ['D:\**经营管理系统2007版\BJACCOUNT.EXE', 'E:\**经营管理系统2007版\BJACCOUNT.EXE', 'C:\**经营管理系统2007版\BJACCOUNT.EXE','F:\**经营管理系统2007版\BJACCOUNT.EXE', 'G:\**经营管理系统2007版\BJACCOUNT.EXE','H:\**经营管理系统2007版\BJACCOUNT.EXE','I:\**经营管理系统2007版\BJACCOUNT.EXE', 'J:\**经营管理系统2007版\BJACCOUNT.EXE', 'K:\**经营管理系统2007版\BJACCOUNT.EXE','D:\Program Files\**经营管理系统2007版\BJACCOUNT.EXE', 'E:\Program Files\**经营管理系统2007版\BJACCOUNT.EXE','C:\Program Files\**经营管理系统2007版\BJACCOUNT.EXE', 'F:\Program Files\**经营管理系统2007版\BJACCOUNT.EXE','G:\Program Files\**经营管理系统2007版\BJACCOUNT.EXE', 'H:\Program Files\**经营管理系统2007版\BJACCOUNT.EXE','I:\Program Files\**经营管理系统2007版\BJACCOUNT.EXE', 'J:\Program Files\**经营管理系统2007版\BJACCOUNT.EXE','K:\Program Files\**经营管理系统2007版\BJACCOUNT.EXE','D:\Program Files (x86)\**经营管理系统2007版\BJACCOUNT.EXE', 'E:\Program Files (x86)\**经营管理系统2007版\BJACCOUNT.EXE','C:\Program Files (x86)\**经营管理系统2007版\BJACCOUNT.EXE', 'F:\Program Files (x86)\**经营管理系统2007版\BJACCOUNT.EXE','G:\Program Files (x86)\**经营管理系统2007版\BJACCOUNT.EXE', 'H:\Program Files (x86)\**经营管理系统2007版\BJACCOUNT.EXE','I:\Program Files (x86)\**经营管理系统2007版\BJACCOUNT.EXE', 'J:\Program Files (x86)\**经营管理系统2007版\BJACCOUNT.EXE','K:\Program Files (x86)\**经营管理系统2007版\BJACCOUNT.EXE',]
for i in range(len(proc_list)):try:subprocess.Popen(proc_list[i])#print('程序在:{}'.format(proc_list[i]))breakexcept:#print('程序不在:{}'.format(proc_list[i]))passtime.sleep(3)
wc = uiautomation.WindowControl(searchDepth=1, Name='帐套登陆')
# 设置为顶层
#pyautogui.alert(text="按回车键继续程序", title="提示")  # 窗口前置才能用键盘快捷键
#print('窗口前置才能用键盘快捷键')
#wc.SetTopmost(True)  # 置顶能用快捷键
wc.SetActive(True)
# accnt_Num_txt = wc.EditControl()
# print('accnt_Num_txt',accnt_Num_txt)def creat_file(year_input, mont_input):print('开始运行创建文件夹自定义函数……')with open('**电脑端账套号生成村委会文件夹用.txt', 'r') as f:dic = []for line in f.readlines():line = line.strip('\n')  # 去掉换行符\nb = line.split('\t')  # 将每一行以空格为分隔符转换成列表#print(list(b))dic.append(b)#print(dic)admin_villi_dict=dict(dic)print('账套所在的村委会文件夹列表是:')print(admin_villi_dict)#列表转字典if not os.path.exists('D:\**会计系统导出数据'):os.mkdir('D:\**会计系统导出数据')admin_villi_list=['前锋']year = time.strftime("%Y")print("当前年份是:", year)time1 = str(year_input) + "年" + str(mont_input) + "月"# if year_input==year:#等于#     time1 = time.strftime("%Y%m%d", time.localtime())  # 加上秒不会出现同名# else:#     time1= year_input #赋值#print('创建第3层文件夹folder3_1')folder3_1 = r"D:\**会计系统导出数据" + '\\' + time1 + '收支明细表'#print('判断文件夹是否存在,不存在则创建,文件保存在:'+folder3_1)if not os.path.exists(folder3_1):os.mkdir(folder3_1)#print('创建第4层文件夹folder4_i')for i in range(0,16):folder_admin_villi=time1+admin_villi_list[i]+'收支明细表'folder4_i=r'D:\**会计系统导出数据'+'\\'+ time1 + '收支明细表'+'\\' +folder_admin_villiif not os.path.exists(folder4_i):os.mkdir(folder4_i)#print('创建文件夹:'+folder4_i)return  admin_villi_dict,folder3_1def check_file(folder3_1):# 打开文件path= folder3_1dirs = os.listdir(path)year = time.strftime("%Y")file_accnt_num_list=[]for home, dirs, files in os.walk(path):for file_name in files:#filelist.append(os.path.join(home, file_name))if os.path.splitext(file_name)[1] == '.xls':#print(file_name)file_year = file_name[0:4]  # 截取文件名前4个字符#print(file_year)# os.rename(file, new)  # 进行重命名if file_year == year:# 取整方法是可以去除0,但是遇到字符串不能转化为整型会报错# file_accnt_num=int(file_name[9:12])s = file_name[9:12]file_accnt_num = "".join(s[::1]).lstrip("0")#print(file_accnt_num)else:s = file_name[5:8]file_accnt_num = "".join(s[::1]).lstrip("0")#print(file_accnt_num)file_accnt_num_list.append((file_accnt_num))#print(filelist)#print(file_accnt_num_list)#print('对列表进行排序,查找时可能减少遍历次数。也便于根据账套号顺序查找')#file_accnt_num_list2=file_accnt_num_list.sort()print('sort影响列表本身,sorted不影响列表本身,用sort排序')file_exist_list = sorted(file_accnt_num_list)print('已导出的文件列表','file_exist_list:')print(file_exist_list)print('已导出的文件数量',len(file_exist_list))return file_exist_listdef accnt_login(account_Num):wc1 = uiautomation.WindowControl(searchDepth=1, Name='帐套登陆')# 设置为顶层#pyautogui.alert(text="按回车键继续程序", title="提示")  # 窗口前置才能用键盘快捷键#wc1.SetTopmost(True)  # 置顶能用快捷键wc1.SetActive(True)pc2_1= wc1.PaneControl(searchDepth=1, Name='帐套信息')ec3_8=pc2_1.EditControl(searchDepth=1, Name='', foundIndex=2)ec3_8.SetFocus()#print('ec3_8')#print('账套号输入框的位置是:')#print(ec3_8.BoundingRectangle)pyperclip.copy(account_Num) #account_Num是账套号pyautogui.hotkey('ctrl', 'v')  # 再粘贴pyautogui.press('enter')def user_login():wc1=uiautomation.WindowControl(searchDepth=1, Name='用户注册')# 设置为顶层#wc1.SetTopmost(True)  # 置顶能用快捷键wc1.SetActive(True)pyautogui.press('down')  # 向下选择超级用户pyautogui.press('enter')  # 点击确定pyautogui.press('enter')  # 点击确定#print('超级用户登录成功')def  select_year(screenWidth, screenHeight, year_input):#print('选择年份')#print('深度1')wc1 = uiautomation.WindowControl(searchDepth=1, Name='**经营管理系统V2007 - [收支明细表]')# 设置为顶层#wc1.SetTopmost(True)wc1.SetActive(True)#print(wc1.Name)#print('深度2') #isum自创字母后的数字表示深度#sbc2_1= wc1.StatusBarControl(searchDepth=1, ClassName= 'TStatusBar')pc2_2= wc1.PaneControl(searchDepth=1,ClassName='MDIClient')#print(pc2_2.Name)#工作区#print('深度3')wc3_1= pc2_2.WindowControl(searchDepth=1,Name='收支明细表')#print(wc3_1.Name)  # 工作区#print('深度4')pc4_2= wc3_1.PaneControl(searchDepth=1, ClassName='TPanel',Name= '')#print(pc4_2.BoundingRectangle) #Rect: (0,183,311,1013)[311x830]#print('深度5')# Rect: (1,214,310,442)[309x228]pc5_1 = pc4_2.PaneControl(searchDepth=1, ClassName='TPanel', Name='')if deta_or_not == '                否                ':#print('导出不包含明细')cbc6_2=pc5_1.ComboBoxControl(searchDepth=1,Name='')cbc6_2.SetFocus()pyautogui.press('down')year = time.strftime("%Y")rbc6_14 = pc5_1.RadioButtonControl(searchDepth=1, Name='指定年月')# print('点击:' + rbc6_14.Name)rbc6_14.Click()pyautogui.press('tab')pyperclip.copy(year_input)pyautogui.hotkey('ctrl', 'v')cbc6_3 = pc5_1.ComboBoxControl(searchDepth=1, ClassName='TComboBox', foundIndex=2)mont_show = cbc6_3.GetValuePattern().Value  # month show会计系统4# 显示月份# print(mont_show)pyautogui.press('tab')for c in range(len(mont_list)):if mont_show == mont_list[c]:  # 一月对应的i是0# print('c+1')# print(c+1)#print(mont_list[c])if mont_input > c + 1:for t in range(abs(mont_input - (c + 1))):pyautogui.press('down')else:for t in range(abs(mont_input - (c + 1))):pyautogui.press('up')# #print("当前年份是:", year)# if year_input!=year:#     #print('深度6')#     rbc6_14 = pc5_1.RadioButtonControl(searchDepth=1, Name='指定年月')#     #print('点击:' + rbc6_14.Name)#     rbc6_14.Click()#     pyautogui.press('tab')##     pyperclip.copy(year_input)#     pyautogui.hotkey('ctrl', 'v')#     #print('按tab键切换到月份下拉菜单,按向下按钮,一直到十二月')#     pyautogui.press('tab')#     for i in range(0,12):#         pyautogui.press('down')# else:##     rbc6_13 = pc5_1.RadioButtonControl(searchDepth=1, Name='当前年月')#     #print('点击:' + rbc6_13.Name)#     rbc6_13.Click()time.sleep(1)pyautogui.click(screenWidth/25.6 , screenHeight/18 ) #点击(75,60 )刷新,入账审核过帐后,第一次查询收支明细表需要刷新。否则只能查询到上个月的数据。# #代替三方鼠标定位软件
# x1,y1,x2,y2=700,27,788,51 #另选账套位置
# x1,y1,x2,y2=316,184,1919,986 #收支明细表显示的范围
# x1,y1,x2,y2=259,560,1607,700#空白的区域
# x1,y1,x2,y2=315,183,1920,1013
# # pyautogui.moveTo(x1,y1,duration=2)
# # pyautogui.moveTo(x2,y1,duration=2)
# # pyautogui.moveTo(x2,y2,duration=2)
# # pyautogui.moveTo(x1,y2,duration=2)
# # pyautogui.moveTo(x1,y1,duration=2)
#
#def to_excel(screenWidth, screenHeight, year_input, mont_input, accnt_Num_name, i,admin_villi_dict):pyautogui.click(screenWidth / 8.5333, screenHeight /15.4286)  # 系统小等字体点击导出(225,70)time.sleep(0.5)# pyautogui.click(590,80)  #点击导出# time.sleep(1)pyautogui.press('down') #按向下键,选择导出Excel表格time.sleep(0.5)pyautogui.press('enter')  # 点击确定pyautogui.keyDown('backspace')#长摁删除键time.sleep(0.5)pyautogui.keyUp('backspace')#time1 =time.strftime("%Y%m%d%H%M%S", time.localtime())#加上秒不会出现同名year = time.strftime("%Y")#print("当前年份是:", year)# if year_input==year:#等于#     time1 = time.strftime("%Y%m%d", time.localtime())  # 加上秒不会出现同名# else:#     time1= year_input #赋值#file_path= r"D:\**会计系统导出数据"+'\\'+time1+'现金三栏明细账'+'\\'+file_name+'.xls'#字典必须传入字符串,admin_villi_dict[str(i)]time1 = str(year_input) + "年" + str(mont_input) + "月"file_path = r"D:\**会计系统导出数据" + '\\'  + time1 + '收支明细表'+ '\\' +time1+admin_villi_dict[str(i)]+'收支明细表'if not os.path.exists(file_path):print('如果没有预先归类到行政村文件夹,就放在上一级文件夹')file_path = r"D:\**会计系统导出数据" + '\\' + time1 + '收支明细表'# print('判断文件夹是否存在,不存在则创建,文件保存在:'+file_path)# if not os.path.exists(file_path):#     os.mkdir(file_path)file_name = time1 + " " + accnt_Num_name + "收支明细表"file_title = time1 + "收支明细表(" + accnt_Num_name + ")"print('文件保存路径是:'+file_path)file_full_path = file_path + '\\' + file_name + '.xls'print("文件名是:",end="")print(file_name)#pyautogui.typewrite(file_name) #不能写入中文pyperclip.copy(file_full_path)  # 写入文件名pyautogui.hotkey('ctrl', 'v')  # 再粘贴pyautogui.press('enter')  # 点击确定print('导出Excel表会自动打开,所以需要等待较长时间。')time.sleep(20)#等待自动打开Excel,必须足够长时间,不然会出现文件名出现不了wc1 = uiautomation.WindowControl(searchDepth=1, Name='**经营管理系统V2007 - [收支明细表]')wc1.Minimize()#最小化缩小窗口pyautogui.click(screenWidth/3.9184, screenHeight/4.9091)#点击Excel表格的标题,修改标题。(490,220)## print('置顶WPS')# def set_top1():#     pyautogui.keyDown('alt')  # 开始运行代码时,任务栏打开的程序只有Python代码运行软件#     pyautogui.press('Tab')#     pyautogui.keyUp('alt')#     #alt+tab快捷键两个窗口来回切换,比win+tab切换好。#     # pyautogui.keyDown('win')  #开始运行代码时,任务栏打开的程序只有Python代码运行软件#     # pyautogui.press('Tab')#     # pyautogui.press('Tab')##     # pyautogui.press('Tab')#     # pyautogui.press('Tab')#     # pyautogui.keyUp('win')#     find_data = re.compile('.*收支明细表.xls.*')#     wc1_3 = uiautomation.WindowControl(searchDepth=1, RegexName=find_data)#正则方法查找控件#     print('wc1_3:',end='')#     print(wc1_3)#     wc1_3.SetFocus(True)#     wc1_3.SetActive(True)#     wc1_3.SetTopmost(True)#     print('置顶WPS文件(正则方法查找控件){}'.format(find_data))## def set_top2():#     find_data = re.compile('.*收支明细表.xls.*')#     wc1_3 = uiautomation.WindowControl(searchDepth=1, RegexName=find_data)#正则方法查找控件#     print('wc1_3:',end='')#     print(wc1_3)#     wc1_3.SetTopmost(True)#     print('置顶WPS文件(正则方法查找控件){}'.format(find_data))# def set_top3():#     find_data = re.compile('.*收支明细表.xls.*')#     wc1_3 = uiautomation.WindowControl(searchDepth=1, RegexName=find_data)#正则方法查找控件#     print('wc1_3:',end='')#     print(wc1_3)#     wc1_3.SetTopmost(True)#     print('置顶WPS文件(正则方法查找控件){}'.format(find_data))# def set_top4():#     wc1_2= uiautomation.WindowControl(searchDepth=1, ClassName='KPromeMainWindow')#     wc1_2.SetTopmost(True)#     print('uiautomation能定位到WPS控件。')# def set_top5():#     Name = '{}.xls - WPS Office'.format(file_name)#     uiautomation.WindowControl(searchDepth=1, Name=Name).SetTopmost(True)#     print('第一种方法查找控件,置顶WPS文件{}'.format(Name))## for func in [set_top1, set_top2, set_top3, set_top4, set_top5]:#     try:#         func()#     except Exception:#         pass#     else:#         break# try:#     #Name = '{}.xls - WP...'.format(file_name)#     Name = '{}.xls - WPS Office'.format(file_name)#     uiautomation.WindowControl(searchDepth=1, Name=Name).SetTopmost(True)#     print('第一种方法查找控件,置顶WPS文件{}'.format(Name))# except:#     pass## try:#     find_data = re.compile('.*收支明细表.xls.*')#     wc1_3 = uiautomation.WindowControl(searchDepth=1, RegexName=find_data)#正则方法查找控件#     print('wc1_3:',end='')#     print(wc1_3)#     wc1_3.SetTopmost(True)#     print('置顶WPS文件(正则方法查找控件){}'.format(find_data))# except:##     pass# try:#     wc1_2= uiautomation.WindowControl(searchDepth=1, ClassName='KPromeMainWindow')#     wc1_2.SetTopmost(True)#     print('uiautomation能定位到WPS控件。')# except:#     pyautogui.keyDown('win')  ##     pyautogui.press('Tab')##     pyautogui.press('Tab')#     pyautogui.press('Tab')##     pyautogui.press('Tab')#     pyautogui.keyUp('win')pyautogui.typewrite(" ")pyautogui.press('backspace')#yautogui.press('insert')  #print('修改表格标题:'+file_title)pyperclip.copy(file_title)  # 写入表格标题pyautogui.hotkey('ctrl', 'v')  # 再粘贴time.sleep(1)pyautogui.hotkey('ctrl', 's')  # 保存Exceltime.sleep(1)pyautogui.hotkey('alt', 'f4')  # 关闭Excel# time.sleep(0.5)# pyautogui.press('enter')  # 点击确定,保存更改time.sleep(1)wc1.Restore() #将窗口回复到最大化return  file_full_path#这里需要加一个,假如保存文件失败之后,**系统错误提示#标题是错误,内容是路径不存在或者文件不可写! 确定。#pyautogui.press('enter')def chage_accnt():#print('深度1')wc1 = uiautomation.WindowControl(searchDepth=1, Name='**经营管理系统V2007 - [收支明细表]')# 设置为顶层#wc1.SetTopmost(True)wc1.SetActive(True)#print(wc1.Name)#print('深度2') #isum自创字母后的数字表示深度#sbc2_1= wc1.StatusBarControl(searchDepth=1, ClassName= 'TStatusBar')pc2_2= wc1.PaneControl(searchDepth=1,ClassName='MDIClient')#print(pc2_2.Name)#工作区mbc2=wc1.MenuBarControl(searchDepth=1, Name= '应用程序')#print('mbc2')#print(mbc2.Name)mic3_9=mbc2.MenuItemControl(searchDepth=1, Name='', foundIndex=9)#print('mic3_9')#print(mic3_9.BoundingRectangle)#(700,27,788,51)[88x24]#print('点击另选账套')mic3_9.Click()#另选账套的坐标:Rect: (700,27,788,51)#这四个 参数 分别代表的意思是: left   top   right   bottom   是 左 上 右 下。def open_fold():# #open folder,打开文件夹--我的文档,其实用win+E快捷键更快### SEE_MASK_NOCLOSEPROCESS = 0x00000040# SEE_MASK_INVOKEIDLIST = 0x0000000C## class SHELLEXECUTEINFO(ctypes.Structure):#     _fields_ = (#         ("cbSize", ctypes.wintypes.DWORD),#         ("fMask", ctypes.c_ulong),#         ("hwnd", ctypes.wintypes.HANDLE),#         ("lpVerb", ctypes.c_char_p),#         ("lpFile", ctypes.c_char_p),#         ("lpParameters", ctypes.c_char_p),#         ("lpDirectory", ctypes.c_char_p),#         ("nShow", ctypes.c_int),#         ("hInstApp", ctypes.wintypes.HINSTANCE),#         ("lpIDList", ctypes.c_void_p),#         ("lpClass", ctypes.c_char_p),#         ("hKeyClass", ctypes.wintypes.HKEY),#         ("dwHotKey", ctypes.wintypes.DWORD),#         ("hIconOrMonitor", ctypes.wintypes.HANDLE),#         ("hProcess", ctypes.wintypes.HANDLE),#     )## ShellExecuteEx = ctypes.windll.shell32.ShellExecuteEx# ShellExecuteEx.restype = ctypes.wintypes.BOOL## sei = SHELLEXECUTEINFO()# sei.cbSize = ctypes.sizeof(sei)# sei.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_INVOKEIDLIST## # sei.lpVerb = "properties"# # sei.lpFile = "D:\\**会计系统导出数据\\2020序时簿\\2020 245居委会序时簿.xls"## sei.nShow = 1# ShellExecuteEx(ctypes.byref(sei))## pyautogui.press('tab')# pyautogui.press('tab')# # pyautogui.press('tab')# # pyautogui.press('tab')# # pyautogui.press('tab')pyautogui.hotkey('win', 'e')pyautogui.press('tab')#pyautogui.press('insert')pyautogui.press('enter')pyperclip.copy('D:\**会计系统导出数据')pyautogui.hotkey('ctrl', 'v')pyautogui.press('enter')def func(year_input, mont_input):#print('当前屏幕分辨率宽 X 高:')screenWidth, screenHeight = pyautogui.size()#print(screenWidth, screenHeight)  # 屏幕分辨率1920 1080,导出的按钮595,80year = time.strftime("%Y")#print("当前年份是:", year)#year_input = pyautogui.prompt('请输入账套查询的年份:')#print('弹窗输入年份:' + year_input)#print('不要把创建文件夹自定义函数放在循环内,先创建文件夹……')admin_villi_dict,folder3_1 = creat_file(year_input, mont_input)#print('遍历3级文件夹下所有文件,检查表格上账套号对应的Excel表是否已导出')file_exist_list=check_file(folder3_1)print('Excel文件上要导出的文件数量及文件列表是:','list_accnt_dict(要先将字典的键转化为字符串格式,两个列表的元素都是字符串才能做减法)')list_accnt_dict= [str(t) for t in list(accnt_dict)]print(len(list_accnt_dict),list_accnt_dict)print('已导出的数量及文件列表', 'file_exist_list:')print(len(file_exist_list),file_exist_list)#print('删除两个列表重复值,一个列表减去另一个列表,用set(集合)操作')accnt_list2=list(set(list_accnt_dict)-set(file_exist_list))#方法2# accnt_list2=list(set(list_accnt_dict))# list(set(file_exist_list))# for n in (list_accnt_dict):#     for m in (file_exist_list):#         if n==m:#             accnt_list2.remove(m)print(accnt_list2)print('sort影响列表本身,sorted不影响列表本身,用sort排序')accnt_list2 = sorted(accnt_list2)print('未导出的文件数量及文件列表是:')print(len(accnt_list2),accnt_list2)file_numb =0for i in accnt_list2:#print('i在之前转化为字符串,要重新转化为数值格式')i=int(i)#print('直接用遍历字典的键值循环,i就是账套号')accnt_Num_name=accnt_dict[i]print('账套号是:' + str(i)+',账套名称是:'+accnt_Num_name)time.sleep(1)#账套号登录自定义函数accnt_login(i)time.sleep(1)#用户登录自定义函数user_login()time.sleep(1)#第二次循环时,科目余额点击# 选项出现较慢,需要等待#print('点击收支明细表')pyautogui.click(screenWidth / 3.9587, screenHeight / 1.125)  # 系统小字体显示,点击收支明细表(485,960)time.sleep(1)select_year(screenWidth, screenHeight,year_input)#print('等待2秒,数据生成需要时间')time.sleep(3)print('导出Excel表涉及到创建文件夹,创建文件,需要输入屏幕长宽、年份、账套号、账套名称、账套所在村委会字典')file_full_path= to_excel(screenWidth, screenHeight, year_input, mont_input, accnt_Num_name, i,admin_villi_dict)time.sleep(3)# print('系统中等字体显示点击另选账套')# pyautogui.click(722,37)  #另选账套#account_Num+=1#print('系统小字体显示点击另选账套坐标135,36')pyautogui.click(screenWidth/3.2,screenHeight/30)  #另选账套time.sleep(3)#另选账套必须足够长时间,因为窗口切换幅度大file_numb+=1print('导出第{}个文件'.format(file_numb))#pyautogui.alert(text=r"文件保存在D:\**会计系统导出数据", title="提示")  #
if __name__ == "__main__":#creat_file('2019')print('桌面上只打开运行代码的程序,其他程序都最小化。')year_input = str(year_input)print(year_input)# for mont_input in range(1, 2):#     func(year_input, mont_input)func(year_input, mont_input)# for year_input in range(2021, 2018, -1):#     year_input=str(year_input)#     print(year_input)#     func(year_input)#open_fold()

python自动化:uiautomation、pyautogui操作会计记账系统(2)处理收支明细表相关推荐

  1. python自动化:uiautomation、pyautogui操作会计记账系统(6):打印会计凭证

    python自动化:uiautomation.pyautogui操作会计记账系统(6):打印会计凭证 #coding=utf-8 #Beijia print account document打印会计凭 ...

  2. python自动化:uiautomation、pyautogui操作会计记账系统(3):处理序时簿

    python自动化:uiautomation.pyautogui操作会计记账系统(1):处理序时簿 #coding=utf-8 #chronological book,查询序时簿 import xlr ...

  3. python自动化:uiautomation、pyautogui操作会计记账系统(5):财务公开

    python自动化:uiautomation.pyautogui操作会计记账系统(5):财务公开 #coding=utf-8 #Beijia To Excel accounting disclosur ...

  4. python自动化:uiautomation、pyautogui操作会计记账系统(7):自动化填写会计软件系统

    python自动化:uiautomation.pyautogui操作会计记账系统(7):自动化填写会计软件系统 #coding=utf-8 #python自动化填写会计软件系统. import xlr ...

  5. task03:python自动化之word操作

    python自动化之word操作 文章目录 python自动化之word操作 一.课前准备 二.知识要点 1.预热:初步认识docx (1)新建空白word并插入文字 2. 正式:python自动化之 ...

  6. Task 03 python自动化之word操作

    1.课前准备 """学习路径均来源于DataWhale"" python 处理 Word 需要用到 python-docx 库,终端执行如下安装命令: ...

  7. 自动化办公-3.python自动化之word操作

    一.课前准备 python 处理 Word 需要用到 python-docx 库,终端执行如下安装命令: pip3 install python-docx 备注:可能word用的少,这块并没认真,但是 ...

  8. Python自动化开发基础 项目实战-监控系统 Day16-李杰-专题视频课程

    Python自动化开发基础 项目实战-监控系统 Day16-14487人已学习 课程介绍         课程特色:实战,细致,生动,深入浅出 适用人群:适合Python初学者 课程详情:从0基础开始 ...

  9. python自动化库_Python操作自动化库PyAutoGUI的方法

    Python操作自动化库PyAutoGUI的方法 发布时间:2020-07-23 17:24:46 来源:亿速云 阅读:73 作者:小猪 这篇文章主要讲解了Python操作自动化库PyAutoGUI的 ...

  10. python办公自动化代码_[Python] 自动化办公 邮件操作基础知识及代码(下)

    转载请注明:陈熹 chenx6542@foxmail.com (简书号:半为花间酒) 若公众号内转载请联系公众号:早起Python 这篇文章能学到的主要内容: imbox 收取邮件 poplib 收取 ...

最新文章

  1. PostgreSQL与MySQL比较
  2. Nginx + Node + Vue 部署初试(修改)
  3. virtualbox 安装虚拟机(centos7) 并映射本地文件夹至虚拟机(增强工具)
  4. 循环遍历多层json_面试官:JSON.stringify() 实现深拷贝有什么问题
  5. Magento: 自定义用户登录导向页面 Redirect Customer to Previous Page After Login
  6. Spring Cloud EurekaService 服务部署服务注册与发现(一)
  7. oracle关于时间的处理,如计算间隔天数、获取本年第一天、上月第一天、上月最后一天
  8. matlab2c使用c++实现matlab函数系列教程-det函数
  9. Windows下安装NetCat
  10. 工程图样中粗实线的用途_电气工程图的一般特点、设计规范
  11. 收集bug开源框架_百度开源又一力作发布!炸了。。。
  12. 编码器计数原理与电机测速原理——多图解析
  13. github 使用笔记之高级搜索、项目跳转到在线 IDE -- 网页版 VS code
  14. 想自己搭建服务器,永久运行网站?一个U盘大小的树莓派就够了!
  15. 程序员眼中的中国传统文化-王阳明《传习录》16
  16. HyperX Alloy Mars2游戏机械键盘,深耕专业电竞机游戏械键盘
  17. 清华大学计算机吴教授,清华大学计算机系教授吴文虎到我校讲学
  18. 熊写代码这三年:阅读写作与技术成长
  19. 溶剂可及性(一):基本概念
  20. HDU steps 1.2.6 Identity Card

热门文章

  1. Python 流媒体播放器(基于VLC)
  2. 深圳大学计算机研究生调剂,深圳大学2020年硕士研究生招生调剂办法
  3. 如何爬取B站视频的封面图片
  4. Unity 实现两个向量夹角为0~360度
  5. modbus模拟器使用
  6. 微信公众号图文消息悄悄调整,注定10月12号是个不眠夜
  7. 乐虎 尖叫_如果您想更快地尖叫! 为什么政府技术需要(很多)更好的治理
  8. 老虎并不吃老虎,只有人用人来养肥自己
  9. wifi+遥控器+android,基于安卓手机wifi的智能遥控器设计
  10. 《互联网信息资源检索与利用》读书笔记