pywinauto:如何选择此对话框?使用哪种间谍工具?我需要什么信息? [英] pywinauto: How to select this dialog? Which spying tool to use? What information do I need on it?

查看:708
本文介绍了pywinauto:如何选择此对话框?使用哪种间谍工具?我需要什么信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在7-zip添加到存档对话框的第一个字段上写 hello?

How can I write "hello" on the first field of the 7-zip "Add to Archive" dialog?

到目前为止,我设法触发了7- zip(Windows 64x)使用pywinauto.application import的

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 Files\7-Zip\7zFM.exe") #set the app
app.top_window_().Edit.type_keys(r"C:\Users\me\Desktop{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:这没有用。我猜是因为它没有找到对话框。如果是,为什么?

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:这也不起作用:

app.window(title_re="Add to Archive", class_name="#32770").Edit.type_keys("hello")

3:我尝试使用 print(app.windows())

但它会显示以下内容:

[<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>]

我看不到任何添加到存档窗口??那些东西是什么(例如in32_controls.DialogWrapper)?

I don't see any "Add to Archive" windows, why? What are those things (eg. in32_controls.DialogWrapper)?

不同间谍工具的打印屏幕
对话框的spy ++ $ b

Print screen of different spy tools spy++ for the dialog

spy ++(显示 Edit,但au

spy++ on the first control (it says Edit, but au

inspect.exe作为对话框:

inspect.exe for the dialog:

推荐答案

我看到 7zFM.exe 使用此对话框生成了另一个进程(甚至是另一个可执行文件!),您需要连接到新进程。

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()

如果打开任务管理器(Win8.1或Win10上的详细信息选项卡),您将看到进程 7zG。 exe 。另一种查看方式:在Spy ++中,当您查看Windows层次结构时,右键单击对话框添加到存档并选择属性,然后切换到带有ProcessID值的标签(显示为十六进制数字)。比较文件管理器对话框的相似编号。

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!

在Inspect.exe中,您还可以看到属性 ProcessId (== 5304 )。在任务管理器/详细信息/列 PID 中找到此值。

In Inspect.exe you can also see property ProcessId (== 5304 on your screenshot). Find this value in Task Manager / Details / column PID.

这篇关于pywinauto:如何选择此对话框?使用哪种间谍工具?我需要什么信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆