皮温汽车filexplorer.exe列出文件

2024-04-25 04:59:38 发布

您现在位置:Python中文网/ 问答频道 /正文

我在windows 10计算机上,我想在列表视图中获取item\u texts()属性。你知道吗

代码如下:

from pywinauto import Application, keyboard
import pywinauto
import time
app = Application().start( "C:\Windows\explorer.exe")
file_explorer_win_info = pywinauto.findwindows.find_window(title = "File Explorer")
file_explorer_win = app.window(handle = file_explorer_win_info)
search_folder = r"C:\Put_whatever_folder_you_want"
file_explorer_win.set_focus()
file_explorer_win["Address band toolbarToolbar"].click()
keyboard.send_keys(search_folder,with_spaces=True)
keyboard.send_keys("{ENTER}")

这将带您到计算机上的特定文件夹,然后我要列出该文件夹中的文件。你知道吗

然后可以运行:

file_explorer.print_control_identifiers()

或者

for cnt,item in enumerate(file_explorer.children()):
       print(cnt,item)

查找要选择哪个子级作为列表视图。我就是找不到。你知道吗

我似乎找不到键或子标识符,无法进入窗口的列表“项视图”部分,然后使用item\u texts()获取列表中项的名称/文本。 在search\u folder(search\u folder)末尾包含文件名/文件名.txt)上面没有做我需要做的事情,因为我需要双击文件才能正常工作。(这与google的api和creds模块的正常工作有关。事先非常感谢。你知道吗


Tags: import视图app列表searchapplication计算机folder