Python Forum
Help ~ coding with pywinauto
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help ~ coding with pywinauto
#1
hi

i would like automate the windows task using pywinauto for my VPN

i am getting an issue to detect the element properly and access the element
some dont not have automation ID / name / title , some have ambigious (more than 1 element) with same name / titke
print_control_identifiers() will return me few hundred line of name but almost all of it not able to access thru clicks (or at least i try)

i got try get inspect.exe , spy++ , accessibilities tool but i am having difficulties to understand the path / useful information to access the item


hope to get some guidance / real example on how to make it work
i had go thru the documentation but it does not help

example code i try to make it click on the different server


import pyautogui
from pywinauto.application import Application

app = Application(backend="uia").connect(title='Proton VPN', visible_only=False)
app .child_window(auto_id="SearchInput", control_type="Edit").type_keys("UNITED STATES")
taking ProtonVpn as example
Reply
#2
It seems like you are trying to automate some tasks related to the Proton VPN client using pywinauto, but you are having trouble identifying the elements you need to interact with. Here are some general tips that may help:

1. Use the Inspect tool to inspect the elements of the Proton VPN client. This tool can provide you with useful information about the elements' properties such as their class name, automation ID, and control type.

2. Try using different properties to identify the elements you need to interact with. For example, if an element does not have an automation ID, you may be able to use its class name or its text to identify it.

3. Use the print_control_identifiers() method to get a list of all the elements and their properties. This can be useful for identifying the elements you need to interact with, even if they do not have easily recognizable properties.

4. Use the wait() method to wait for an element to appear on the screen before trying to interact with it. This can help avoid errors that may occur if you try to interact with an element that is not yet visible.

5. Use the click_input() method to simulate a mouse click on an element. This can be used to interact with buttons, checkboxes, and other clickable elements.

Here is an example code snippet that demonstrates how to click on a server in the Proton VPN client using pywinauto:

from pywinauto.application import Application
import time

app = Application(backend="uia").connect(title='Proton VPN', visible_only=False)
server_list = app.child_window(title="Server List", control_type="List")
server_list.click_input()  # Click on the server list to focus it

# Wait for the server list to become visible
server_list.wait('visible', timeout=10)

# Find the server you want to click on
server_name = "UNITED STATES"
server = server_list.child_window(title=server_name, control_type="ListItem")

# Click on the server
server.click_input()
This code assumes that the Proton VPN client is already running and visible on the screen, and that the server list is already open. The code uses the wait() method to wait for the server list to become visible, and then uses the child_window() method to find the server with the specified name. Finally, the code uses the click_input() method to simulate a mouse click on the server, which should connect to it.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  MemoryError in pywinauto.findwindows.find_windows – Need Help! ktw3857 1 333 Apr-18-2024, 04:28 PM
Last Post: itegumo
  Pywinauto typing in the wrong field EGameiro 0 687 Jun-07-2023, 10:01 PM
Last Post: EGameiro
  pywinauto, anyone use it? thewolf 1 2,851 Mar-01-2021, 09:58 PM
Last Post: snippsat
  set_focus() in python pywinauto stearno 0 4,778 Nov-05-2020, 09:34 AM
Last Post: stearno
  Kindly asking for help with Pywinauto louloulou 0 2,032 Mar-05-2020, 06:55 PM
Last Post: louloulou
  Checking the presence of label using pywinauto module Malt 0 1,936 Jul-26-2019, 09:06 AM
Last Post: Malt
  [PyWinAuto] Please help me with Typekeys () mattroi261192 2 7,916 Apr-23-2019, 01:55 AM
Last Post: mattroi261192
  Not able to convert PYWINAUTO module automation in exe file Utkarsh29 0 2,459 Mar-19-2019, 09:39 PM
Last Post: Utkarsh29
  pywinauto problems vnc 3 8,178 Apr-13-2017, 11:21 AM
Last Post: vnc
  pywinauto timings timout error stonetr33 4 11,502 Dec-07-2016, 12:55 AM
Last Post: Yoriz

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020