Pywinauto の基本 02 -- ウィンドウ操作

1. プログラムウィンドウの操作

1. プログラム ウィンドウの名前またはクラス名を使用して、ウィンドウまたはそのサブウィンドウを見つけます。

window = app['test001.txt - 记事本']
from pywinauto.application import Application
# 通过窗口句柄连接已经启动的记事本程序,记事本的窗口句柄NativeWindowHandle为2564730
handle = 2564730
app = Application(backend='uia').connect(handle=handle)

# 通过窗口title指定待操作窗口
window = app['test001.txt - 记事本']

# 控台输出该窗口下所有的子窗口的类名、标题、位置、控制类型等信息
window.print_control_identifiers()

2. プログラムウィンドウの名前またはクラス名を指定して検索します。

window = app.window(title='test001.txt - 记事本', class_name='Notepad')

3. タイトル名が長すぎる場合は、title_re の通常ルールを使用してバインドして検索します。

window = app.window(title_re='.*est001.*')

4. 一番上のウィンドウの位置を要求します (必ずしも予想されるウィンドウであるとは限りません)

window = app.top_window()
from pywinauto.application import Application
# 通过窗口句柄连接已经启动的记事本程序,记事本的窗口句柄NativeWindowHandle为2564730
handle = 2564730
app = Application(backend='uia').connect(handle=handle)

# 请求最顶部窗口(也不一定是预期的窗口)
window = app.top_window()

# 输出记事本窗口标题
main_title = window.get_properties()['texts'][0]
print(main_title)

おすすめ

転載: blog.csdn.net/nikeylee/article/details/129476635
おすすめ