windows 如何在 pywinauto 中找到可用的对话框和应用程序控件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8008490/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 18:23:45  来源:igfitidea点击:

How can i find available dialogs ,controls of an application in pywinauto?

pythonwindowspywinauto

提问by GiannisIordanou

I am using pywinauto in windows 7 and I am searching for a way to find the available dialogs and controls of an application.The following is an example:

我在 Windows 7 中使用 pywinauto,我正在寻找一种方法来查找应用程序的可用对话框和控件。以下是一个示例:

from pywinauto import application
import time

app=application.Application()
app.connect_(title_re = ".*Notepad", class_name = "Notepad")

You can start or connect to an application with pywinauto.But I don't know how can I find whats available in notepad.Any ideas ? Thanks.

您可以使用 pywinauto 启动或连接到应用程序。但我不知道如何在记事本中找到可用的内容。有任何想法吗?谢谢。

回答by LittlePanda

This is working for me. Source: http://pywinauto.github.io/docs/getting_started.html

这对我有用。来源:http: //pywinauto.github.io/docs/getting_started.html

from pywinauto import application

app = application.Application.Start("Notepad.exe")
app.Notepad.print_control_identifiers()
app.Notepad.MenuSelect("Edit->Replace")
app.Replace.print_control_identifiers()

Or you can use Swapyto see all controls and class names

或者你可以使用Swapy查看所有控件和类名

enter image description here

在此处输入图片说明

回答by bagus prasojo

You can find what available in app by executing print_control_identifiers(). Try this code :

您可以通过执行 print_control_identifiers() 找到应用程序中可用的内容。试试这个代码:

app.print_control_identifiers()