by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 16:24
    dschiller commented #985
  • 16:23
    dschiller commented #985
  • 16:22
    dschiller commented #985
  • 16:22
    dschiller commented #985
  • 16:12
    dschiller commented #985
  • 12:24
    prcciencecc commented #986
  • 10:12
    airelil commented #985
  • 07:55
    dschiller commented #985
  • 05:38
    airelil commented #986
  • 05:34
    airelil commented #985
  • Sep 24 14:01
    prcciencecc opened #986
  • Sep 24 09:39
    dschiller edited #985
  • Sep 24 09:38
    dschiller opened #985
  • Sep 22 20:02
    robertschulze commented #957
  • Sep 22 00:14
    rgov commented #957
  • Sep 21 23:18
    robertschulze commented #957
  • Sep 18 10:56
    dschiller commented #981
  • Sep 18 10:36
    vasily-v-ryabov closed #977
  • Sep 18 10:34
    vasily-v-ryabov commented #981
  • Sep 17 13:44
    shivakrishnach31 edited #984
Vasily Ryabov
@vasily-v-ryabov
Login window might be a child of another top level window. It’s typical situation for “uia” backend.
_fantasticDev_
@SnakeGeneral
yes
much thanks.
prolorenzo
@suicide1111

Hello, I have error, can U help me?

def tab1_check(self):
app3 = Application()
app3.start(tab1_path_to_sitelink)
global tab1_connect
tab1_connect = app3.process
print(tab1_connect)
self.tab1_sod()

def tab1_sod(self):
try:
app2 = Application(backend="uia").connect(process=f'{tab1_connect}', visible_only=False)

    s_o_d = app2.window(process=f'{tab1_connect}')

raise ProcessNotFoundError('Process with PID={} not found!'.format(self.process))

pywinauto.application.ProcessNotFoundError: Process with PID=16508 not found!

Vasily Ryabov
@vasily-v-ryabov
process param is an integer PID (process id). Why using f-string? :) Also it’s possible that you face the launcher process that spawns a child one. Use connect by title with optional timeout to connect to proper process. We have feature request to implement auto detection of child processes, but it’s not expected soon.
Mohamed Hamdy
@draconlord
hello all can anyone advice the best setup approach for the pywinauto over win10 64 bit ?
tried python 3.8.1, 3.6 and no luck i always get AttributeError: module 'pywinauto' has no attribute 'application'
using pycharm and the python console works ok when i state from pywinauto import Application
Vasily Ryabov
@vasily-v-ryabov
Hi @draconlord do you mean Python 3.7.6? Both these Python versions have wrong fix for “passing union by value”. The wrong fix is already reverted in Python. Wait for Python 3.8.2 or use 3.8.0 or 3.7.5.
Mohamed Hamdy
@draconlord
@vasily-v-ryabov thank buddy i got it working now
i have a question the app im trying to automate uses check box list not detected by any GUI inspection tool, i know this is app related but i thought you guys could help its a C++ app and i even cant get this dialog using resource hacker either its identified as "pane" class = GLISTCLASS
Vasily Ryabov
@vasily-v-ryabov
@draconlord is it GTK+ app? Everything is bad with GTK on Windows. Really the worst case.
Linux is much much better working with GTK from accessibility point of view.
Vasily Ryabov
@vasily-v-ryabov
@aswathy53408765_twitter let's continue in this room in English.
Mohamed Hamdy
@draconlord
@vasily-v-ryabov it's windows based and all I can get from sniffers scans that it's a VC++ mfc app and not readable by any automation app i.e: ranorex just an element and a scroll bar
Vasily Ryabov
@vasily-v-ryabov
@draconlord I’m in doubt if this is really MFC app. All MFC apps are perfect for automation. Maybe only top level window is an MFC container that contains GTK+ components as children. Can you provide a few screenshots from Inspect.exe in UI Automation mode? For the list and for the main window?
I’ve googled what is GLISTCLASS and it’s GTK. Maybe main window is an MFC container that owns child GTK controls. A few screenshots from Inspect.exe would be helpful.
Mohamed Hamdy
@draconlord
@vasily-v-ryabov here's what inspect shows:
How found: Mouse move (1033,446)
hwnd=0x000709D6 32bit class="GLISTCLASS" style=0x50A00000 ex=0x200
RuntimeId: "[42.461270]"
BoundingRectangle: {l:866 t:369 r:1130 b:549}
ProcessId: 13220
ControlType: UIA_PaneControlTypeId (0xC371)
LocalizedControlType: "pane"
Name: ""
AccessKey: ""
HasKeyboardFocus: false
IsKeyboardFocusable: true
IsEnabled: true
AutomationId: "1"
ClassName: "GLISTCLASS"
HelpText: ""
IsPassword: false
NativeWindowHandle: 0x709D6
IsOffscreen: false
FrameworkId: "Win32"
ProviderDescription: "[pid:7084,providerId:0x709D6 Main:Nested [pid:13220,providerId:0x709D6 Annotation(parent link):Microsoft: Annotation Proxy (unmanaged:uiautomationcore.dll); Main:Microsoft: MSAA Proxy (unmanaged:uiautomationcore.dll)]; Nonclient:Microsoft: Non-Client Proxy (unmanaged:uiautomationcore.dll); Hwnd(parent link):Microsoft: HWND Proxy (unmanaged:uiautomationcore.dll)]"
Scroll.HorizontalScrollPercent: 0.000000
Scroll.HorizontalViewSize: 100.000000
Scroll.VerticalScrollPercent: 0.000000
Scroll.VerticalViewSize: 1.898734
Scroll.HorizontallyScrollable: false
Scroll.VerticallyScrollable: true
IsDockPatternAvailable: false
IsExpandCollapsePatternAvailable: false
IsGridItemPatternAvailable: false
IsGridPatternAvailable: false
IsInvokePatternAvailable: false
IsMultipleViewPatternAvailable: false
IsRangeValuePatternAvailable: false
IsScrollPatternAvailable: true
IsScrollItemPatternAvailable: false
IsSelectionItemPatternAvailable: false
IsSelectionPatternAvailable: false
IsTablePatternAvailable: false
IsTableItemPatternAvailable: false
IsTextPatternAvailable: false
IsTogglePatternAvailable: false
IsTransformPatternAvailable: false
IsValuePatternAvailable: false
IsWindowPatternAvailable: false
IsItemContainerPatternAvailable: false
IsVirtualizedItemPatternAvailable: false
FirstChild: "Vertical" scroll bar
LastChild: "Vertical" scroll bar
Next: (null) title bar
Previous: "" dialogue
Other Props: Object has no additional properties
Children: "Vertical" scroll bar
Ancestors: "Derivatives" window
"View Selection for [Desktop\test.lay]" dialogue
"LayMan - [Desktop\test.lay] " window
"Desktop 1" pane
[ No Parent ]
Vasily Ryabov
@vasily-v-ryabov
@draconlord looks like you're out of luck. Sorry.
LexiconCode
@LexiconCode
Is it possible to obtain a control from cursor?
Vasily Ryabov
@vasily-v-ryabov
@LexiconCode from pywinauto import Desktop; Desktop(backend="uia").from_point(x, y)
LexiconCode
@LexiconCode
That was very helpful thank you!
LexiconCode
@LexiconCode

A couple questions regarding the following code.

from pywinauto import Application
app = Application(backend="uia").connect(process=15900) # Notepad
dlg = app['Untitled - Notepad']
# Timed start
text = app['dlg']['Edit'].get_value() #  329ms to grab the text control
# Timed stop
print(text)
  1. Is there a faster way to retrieve "get_value" before caching?
  2. Reviewing the documentation for https://pywinauto.readthedocs.io/en/latest/code/pywinauto.controls.uia_controls.html#pywinauto.controls.uia_controls.EditWrapper I am a bit confused. I would like to retrieve additional information such as get_value's line_count(). I think I'm confusing the difference between the edit control and its element?

In general my end goal is to be able to:

- Grab Edit/document controls text body
- caret index from beginning of document to current caret position 
- anchor index beginning line index
- anchor position
- grab line index anchor position from the line index. caret indexed at the beginning of the line
- setting the caret/anchor position 

However it seems that caret/anchor is not implemented in pywinauto

Vasily Ryabov
@vasily-v-ryabov
Hi @LexiconCode the faster way to find EditWrapper is using more precise window specification like cached_edit = app.window(title="Main window title").child_window(control_type="Edit", found_index=0).wrapper_object(); chached_edit.get_value() because pre-filtering by control_type reduces list of interesting elements dramatically and it's very fast. So we don't have to retrieve title/text of all elements which is expensive.
1 reply
Vasily Ryabov
@vasily-v-ryabov
Setting caret position can be done by cached_edit.select(caret_index, caret_index) to select empty range of the text. Method .selection_indices() should return currect selection. It might be unreliable to get caret position because caret can be at start of at end of selection. So this is interesting question. Maybe we need to submit enhancement request to GitHub issues.
7 replies
You can try to experiment with cached_edit.iface_text.DocumentRangeobject. For example list all its attributes by dir(doc_range).
LexiconCode
@LexiconCode

So this is interesting question. Maybe we need to submit enhancement request to GitHub issues.

Here is how to grab caret position for the current element using UIautomation in C++ or C#. Would that be enough information start up issue as an enhancement?

2 replies
beuaaa
@beuaaa

Hello, I have developed a Pywinauto "Record/Replay" tool. There is still a lot of work to do but I would like to have first opinions and I'm looking for beta testers.

Here is a small video presentation:
Youtube presentation

beuaaa
@beuaaa
I just realized that pywinauto_recorder.exe doesn't work on all machines (I'll fix this problem later). So to test it I advise you to download the ZIP archive of the clone: https://github.com/beuaaa/pywinauto_recorder/archive/master.zip
Bromus
@Bromus93_twitter
Hey guys I just started getting familiar with PyWinAuto and I created a basic calculator (WPF console in Visual studio 2019) and got the executable for it. I know how to open the application which goes something like app = Application(backend="uia").start('calculator.exe') but I'm not familiar with calling the buttons on my calculator. I have inspect.exe to help me out with the UI element properties so I can see the ControlType but I am not sure how to apply it here
I was thinking something like app.type_key('1*3=')
Vasily Ryabov
@vasily-v-ryabov
Hi @Bromus93_twitter it's worth reading the whole Getting Started Guide. It explains window specification concept and how to find particular element (and its wrapper).
Bromus
@Bromus93_twitter
@vasily-v-ryabov that was very helpful thank you
Bromus
@Bromus93_twitter
So I was able to click on the delete button on my calculator but for some reason whenever I try clicking on any of the special characters like 7, 8 or +, it tells me that Im using invalid syntax. I ran the print_control>identifiers() to make sure that I can see the child windows which I was able to. I did something like app.Off.click() and that worked fine but if i do something like app.7.click() then it doesnt work. Is it because it doesnt like the format of the button's title
Vasily Ryabov
@vasily-v-ryabov
Yes, because attribute name has the same limitations as variable name. It can’t start from digit or special character because of Python syntax. Use app[“7”].click() instead. Item access has no such restrictions. Any string is OK.
Bromus
@Bromus93_twitter
Hey guys is there a version of selected_item_index() from the ListBox for TreeView? I couldnt find it anywhere and was wondering if there was a way to retrieve the index of a tree item
Bromus
@Bromus93_twitter
And this is for Win32
Swaraj Kumar Barik
@swaraj_barik_twitter
Hi All
I'm new to Pywinauto
While I started my application, the pop up opens & closes automatically
how can we handle this?
Vasily Ryabov
@vasily-v-ryabov
Hi @swaraj_barik_twitter please read the Getting Started Guide first, then Waiting for Long Operations. Methods wait() and wait_not() is what you need with proper window specifications.
Vasily Ryabov
@vasily-v-ryabov
@Bromus93_twitter this is not so easy because TreeView items are not populated in a hierarchy for "win32" backend. There is special virtual class _treeview_element which can be created indirectly using method get_item(path) or just item(path)where possible path values can be obtained by method print_items(). Hope it helps.
Bromus
@Bromus93_twitter
Thank you for clarifying that @vasily-v-ryabov
Bromus
@Bromus93_twitter
I am trying to click on a button window by doing something like dlg_button[('Data')].click() but it tells me that the control does not have a get item method for item access. This surprises me because previously i had done something like app[“7”].click() which didnt give me any issues. The only difference is that I had to go down a hierarchy level but regardless I am confused on why this is happening.
Bromus
@Bromus93_twitter
The other difference is that this is WPF
Bromus
@Bromus93_twitter
And the parent control of the button control has a control type of custom
Vasily Ryabov
@vasily-v-ryabov
@Bromus93_twitter what dlg_button['Data'].wrapper_object() returns? Is it TreeViewWrapper object from common_conrols.py?
Bromus
@Bromus93_twitter
@vasily-v-ryabov its just a random button but I actually figured it out the solution code. For some reason it wanted the method toggle() instead of click and it wanted me to specify the control. So it wanted something like dlg.Button.toggle(). That part doesn't bother me as much as me not being able to do something like dlg['data'].click() or dlg['data'].toggle() considering I was able to do this before on other applications for WPF (although now that Im thinking about it that was mainly for ListBox)but to answer your question its a Button wrapper from uia controls and not a TreeViewWrapper from common_controls.py
TheZelja
@thezelja

Hi all. Is there an option to pass "Start in directory" option to:
Application().Start

https://imgur.com/a/3GkSjc7