Application().connect is not getting connected to 'Services' window

27 Views Asked by At

Trying to open Start->Services window and connect pywinAuto Application to Services window using the title 'Services', But the application is not connecting to above mentioned window. The code written to open a Services window and connect with it is as mentioned below:

def search_webroot_in_services():
    childWindowFile='C:\Girish\DnsAutomation\childWindow.txt'
    try:
        #--------------------------
        desktop = Desktop(backend='uia')

        # click to open 'start' menu
        desktop.Pane.Start.click_input()
        desktop.StartMenu.child_window(auto_id="SearchTextBox", control_type="Edit").type_keys('services')
        keyboard.send_keys('{ENTER}')
    #Below line of code is not working
        app=Application(backend='uia').connect(title='Services',timeout=10)
        app.Services.print_control_identifiers()
        
    except Exception as e:
        print(f"Error searching in Services Programs: {str(e)}")
        return False

Would like to connect to Services app, and check if the required services is running is the purpose of writing above code. The image of the Services window being tried to automate is attached.

Tried connecting the Services window using below code, but its not working.

app=Application(backend='uia').connect(title='Services',timeout=10)

enter image description here

0

There are 0 best solutions below