pywin32 怎么获取 windows 的窗体内文本框的内容
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了pywin32 怎么获取 windows 的窗体内文本框的内容相关的知识,希望对你有一定的参考价值。
参考技术A 1234567891011121314151617181920#Win32#打开<a href="/s?wd=EXCEL&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1dBn19BmvDvPvc1rH9BmH9W0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EnW0sP1cdPjRvnjmkn1mYnW6d" target="_blank" class="baidu-highlight">EXCEL</a>WinApp = win32com.client.DispatchEx('<a href="/s?wd=Excel&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1dBn19BmvDvPvc1rH9BmH9W0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EnW0sP1cdPjRvnjmkn1mYnW6d" target="_blank" class="baidu-highlight">Excel</a>.Application')#要处理的<a href="/s?wd=excel&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1dBn19BmvDvPvc1rH9BmH9W0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EnW0sP1cdPjRvnjmkn1mYnW6d" target="_blank" class="baidu-highlight">excel</a>文件路径#out.file是文件 <a href="/s?wd=%E7%BB%9D%E5%AF%B9%E8%B7%AF%E5%BE%84&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1dBn19BmvDvPvc1rH9BmH9W0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EnW0sP1cdPjRvnjmkn1mYnW6d" target="_blank" class="baidu-highlight">绝对路径</a>WinBook = WinApp.Workbooks.Open(out_file) #要处理的excel页WinSheet = WinBook.Worksheets('Sheet1') #单元格添加颜色WinSheet.Cells(1, 1).Interior.ColorIndex = 3#或者Range("A1") WinSheet.Range("A1").Interior.ColorIndex = 3 #3=红色,不同的值代表不同的颜色,可以去查看msdn vba 文档,这就不详细说了 #再是<a href="/s?wd=RGB&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1dBn19BmvDvPvc1rH9BmH9W0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EnW0sP1cdPjRvnjmkn1mYnW6d" target="_blank" class="baidu-highlight">RGB</a>调色方式#Cells 和 Range都可以,Range可以选择一大片区域WinSheet.Cells(1, 1).Interior.Color = <a href="/s?wd=RGB&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1dBn19BmvDvPvc1rH9BmH9W0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EnW0sP1cdPjRvnjmkn1mYnW6d" target="_blank" class="baidu-highlight">RGB</a>(0, 0, 255) #或WinSheet.Range("A1").Interior.Color = <a href="/s?wd=RGB&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1dBn19BmvDvPvc1rH9BmH9W0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EnW0sP1cdPjRvnjmkn1mYnW6d" target="_blank" class="baidu-highlight">RGB</a>(255, 0, 255) #字体的颜色也是一样WinSheet.Cells(1, 1).Font.ColorIndex = 3WinSheet.Cells(1, 1).Font.Color = RGB(0, 0, 255)以上是关于pywin32 怎么获取 windows 的窗体内文本框的内容的主要内容,如果未能解决你的问题,请参考以下文章
python pywin32 里面操作窗体,获取窗体里面的数据,在函数GetDlgItem函数中,怎么获取第二个参数的值?
Pywinauto常用02--pywin32(Python调用win api)
如何使用 pywin32 在 Python 中获取特定应用程序窗口的句柄?