Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding GUI elements with pywinauto

I am trying my first things with pywinauto. Now I want to make use of print_control_identifiers() but I get errors, however I write my code - I cant get any information about GUI objects. I already tried to generate the code via swapy - had a lot of generated code, but no success.

This is my code so far:

import getpass, fnmatch

from pywinauto import application

currentUser = getpass.getuser()

if fnmatch.fnmatch(currentUser, "axe"):
    pwa_app = application.Application()
    w_handle = application.findwindows.find_windows(title=u'Login - 0.9.347', class_name='WindowsForms10.Window.8.app.0.141b42a_r11_ad1')[0]
    window = pwa_app.window_(handle=w_handle)
    window.SetFocus()
    ctrl = window['Log In']
    ctrl.Click()


else:
    print "You need admin rights for that action"

Can you tell me, where I need to use print_control_identifiers()? Do you have any other GUI automation frameworks that are more up-to-date?

like image 723
hazzard Avatar asked Dec 03 '25 12:12

hazzard


1 Answers

PrintControlIdentifiers() is useful for top level window. If window is top level window specification, then just call

window.PrintControlIdentifiers()

or

 pwa_app.Window_(title=u'Login - 0.9.347', top_level_only=True).PrintControlIdentifiers()
like image 121
Vasily Ryabov Avatar answered Dec 06 '25 00:12

Vasily Ryabov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!