pywinauto:如何选择这个对话框?使用哪种间谍工具?我需要什么信息? [英] pywinauto: How to select this dialog? Which spying tool to use? What information do I need on it?
问题描述
如何在 7-zip添加到存档"对话框的第一个字段上写你好"?
到目前为止,我设法使用此方法触发了 7-zip(Windows 64x)添加到存档"对话框
from pywinauto.application import Applicationapp = Application().start(r"C:Program Files7-Zip7zFM.exe") #设置应用app.top_window_().Edit.type_keys(r"C:UsersmeDesktop{ENTER}")app.top_window_().SysListView32.Select(r'test.txt') #选择列表中的文件app.top_window_().ToolbarAdd.TypeKeys("{ENTER}") #apply
然后我无法选择添加到存档"对话框.
1:这不起作用.我猜是因为它没有找到对话框.如果是,为什么?
app.window(title_re="添加到存档", class_name="#32770").print_control_identifiers()
2:这也不起作用:
app.window(title_re="添加到存档", class_name="#32770").Edit.type_keys("hello")
3:我尝试使用 print(app.windows())
但它会打印:
<预> <代码>并[d在0x0000000004033D68>中< pywinauto.controls.win32_controls.DialogWrapper对象; pywinauto.controls.common_controls.ToolTipsWrapper对象在0x0000000004089128>中<在0x0000000004089208 pywinauto.controls.hwndwrapper.HwndWrapper对象>,<pywinauto.controls.win32_controls.DialogWrapper 对象在 0x00000000040893C8>, <pywinauto.controls.win32_controls.DialogWrapper 对象在 0x00000000004089390>]我没有看到任何添加到存档"窗口,为什么?那些东西是什么(例如 in32_controls.DialogWrapper)?
不同间谍工具的打印屏幕用于对话框的间谍++
spy++ 在第一个控件上(它说 Edit,但 au
inspect.exe 对话框:
我看到 7zFM.exe
通过此对话框生成另一个进程(它甚至是另一个可执行文件!).您需要连接到新进程.
app2 = Application().connect(path='7zG.exe', title='Add to Archive')app2.AddToArchive.print_control_identifiers()
如果您打开任务管理器(Win8.1 或 Win10 上的详细信息"选项卡),您将看到进程 7zG.exe
.另一种查看方式:在 Spy++ 中,当您查看 Windows 层次结构时,右键单击对话框添加到存档"并选择属性",然后切换到带有 ProcessID 值的选项卡(显示为十六进制数).比较文件管理器对话框的相似数字.有不同的 ProcessID!
在 Inspect.exe 中,您还可以看到属性 ProcessId
(屏幕截图上的 == 5304).在任务管理器/详细信息/列 PID
中找到此值.
How can I write "hello" on the first field of the 7-zip "Add to Archive" dialog?
I managed so far to trigger the 7-zip (windows 64x) "Add to Archive" dialog using this
from pywinauto.application import Application
app = Application().start(r"C:Program Files7-Zip7zFM.exe") #set the app
app.top_window_().Edit.type_keys(r"C:UsersmeDesktop{ENTER}")
app.top_window_().SysListView32.Select(r'test.txt') #select files in list
app.top_window_().ToolbarAdd.TypeKeys("{ENTER}") #apply
Then I can't select the Add to Archive dialog.
1: This did not work. I guess because it did not find the dialog. If so, why?
app.window(title_re="Add to Archive", class_name="#32770").print_control_identifiers()
2: This also did not work:
app.window(title_re="Add to Archive", class_name="#32770").Edit.type_keys("hello")
3: I tried to find all available dialogs on my app using print(app.windows())
But it prints this:
[<pywinauto.controls.win32_controls.DialogWrapper object at 0x0000000004033D68>, <pywinauto.controls.common_controls.ToolTipsWrapper object at 0x0000000004089128>, <pywinauto.controls.hwndwrapper.HwndWrapper object at 0x0000000004089208>, <pywinauto.controls.win32_controls.DialogWrapper object at 0x
00000000040893C8>, <pywinauto.controls.win32_controls.DialogWrapper object at 0x0000000004089390>]
I don't see any "Add to Archive" windows, why? What are those things (eg. in32_controls.DialogWrapper)?
Print screen of different spy tools spy++ for the dialog
spy++ on the first control (it says Edit, but au
inspect.exe for the dialog:
I see 7zFM.exe
spawns another process (it's even another executable!) with this dialog. You need to connect to the new process.
app2 = Application().connect(path='7zG.exe', title='Add to Archive')
app2.AddToArchive.print_control_identifiers()
[EDIT]
If you open Task Manager (tab "Details" on Win8.1 or Win10) you will see process 7zG.exe
. Another way to see that: in Spy++ when you're looking at the windows hierarchy, right click on the dialog "Add to Archive" and choose "Properties", then switch to tab with ProcessID value (it's shown as a hex number). Compare similar number for the File Manager dialog. There are different ProcessIDs!
In Inspect.exe you can also see property ProcessId
(== 5304 on your screenshot). Find this value in Task Manager / Details / column PID
.
这篇关于pywinauto:如何选择这个对话框?使用哪种间谍工具?我需要什么信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!