Retrieve content inside MessageDialog using pywinauto

0down votefavorite

I am having trouble to automate or atleast retrieve the content present inside a MessageDialog using pywinauto. Can someone help me in overcoming this problem. So, when I use print_control_identifiers() on my dialog I get following output:

Control Identifiers:

DirectUIHWND - ‘’ (L620, T446, R1293, B552) ‘DirectUIHWND’ ‘OKDirectUIHWND’

CtrlNotifySink - ‘’ (L1203, T515, R1283, B543) ‘CtrlNotifySink7’ ‘OKCtrlNotifySink’

Button - ‘OK’ (L1203, T515, R1283, B543) ‘Button’ ‘OK’ ‘OKButton’

I tried using WindowText(), but got nothing. The dialog appearance looks similar attached file. I want to access “File Imported correctly” message.

Capture2.PNG

It cannot be done. The buttons are separate child controls, but the
icon and the message text are written during WM_PAINT handling.
They are drawn each time the window is refreshed, and are not child
windows. There’s no way to find the text.

···

Amrutha Pobbati wrote:

favorite

                    I am

having trouble to automate or atleast retrieve
the content present inside a MessageDialog using
pywinauto. Can someone help me in overcoming
this problem. So, when I use
print_control_identifiers() on my dialog I get
following output:

                    Control

Identifiers:

                    DirectUIHWND
  • ‘’ (L620, T446, R1293, B552) ‘DirectUIHWND’
    ‘OKDirectUIHWND’
                    CtrlNotifySink
  • ‘’ (L1203, T515, R1283, B543)
    ‘CtrlNotifySink7’ ‘OKCtrlNotifySink’
                    Button -

‘OK’ (L1203, T515, R1283, B543) ‘Button’ ‘OK’
‘OKButton’

                    I tried

using WindowText(), but got nothing. The dialog
appearance looks similar attached file. I want
to access “File Imported correctly” message.

-- Tim Roberts, Providenza & Boekelheide, Inc.

timr@probo.com

So, would there be any other way to automate it. I am actually trying to automate a window that pops up this message dialog at one point and I need to check if it the messagedialog shows info as expected

···

On Thursday, December 21, 2017 at 1:52:32 PM UTC-5, Tim Roberts wrote:

Amrutha Pobbati wrote:

favorite

                    I am

having trouble to automate or atleast retrieve
the content present inside a MessageDialog using
pywinauto. Can someone help me in overcoming
this problem. So, when I use
print_control_identifiers() on my dialog I get
following output:

                    Control

Identifiers:

                    DirectUIHWND
  • ‘’ (L620, T446, R1293, B552) ‘DirectUIHWND’
    ‘OKDirectUIHWND’
                    CtrlNotifySink
  • ‘’ (L1203, T515, R1283, B543)
    ‘CtrlNotifySink7’ ‘OKCtrlNotifySink’
                    Button -

‘OK’ (L1203, T515, R1283, B543) ‘Button’ ‘OK’
‘OKButton’

                    I tried

using WindowText(), but got nothing. The dialog
appearance looks similar attached file. I want
to access “File Imported correctly” message.

It cannot be done.  The buttons are separate child controls, but the

icon and the message text are written during WM_PAINT handling.
They are drawn each time the window is refreshed, and are not child
windows. There’s no way to find the text.

-- Tim Roberts, ti...@probo.com
Providenza & Boekelheide, Inc.

You could, potentially, get an image of the dialogue and compare some or
all with a reference image.
http://pywinauto.readthedocs.io/en/latest/code/pywinauto.base_wrapper.html?highlight=PIL#pywinauto.base_wrapper.BaseWrapper.capture_as_image

···

On 21/12/2017 20:20, Amrutha Pobbati wrote:

So, would there be any other way to automate it. I am actually trying to
automate a window that pops up this message dialog at one point and I
need to check if it the messagedialog shows info as expected

On Thursday, December 21, 2017 at 1:52:32 PM UTC-5, Tim Roberts wrote:

    Amrutha Pobbati wrote:

    favorite
    <https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstackoverflow.com%2Fquestions%2F47914863%2Fhow-to-automate-content-inside-messagedialog-using-pywinauto%23&data=02|01||f23f19e80d1346ea623808d548b03dca|84df9e7fe9f640afb435aaaaaaaaaaaa|1|0|636494844137872814&sdata=lmKrMSNVsxyHg8zCMTw%2FLanqtRc6fZHmTuxYgebrREI%3D&reserved=0&gt;

    I am having trouble to automate or atleast retrieve the content
    present inside a MessageDialog using pywinauto. Can someone help
    me in overcoming this problem. So, when I use
    print_control_identifiers() on my dialog I get following output:

    Control Identifiers:

    DirectUIHWND - '' (L620, T446, R1293, B552) 'DirectUIHWND'
    'OKDirectUIHWND'

    CtrlNotifySink - '' (L1203, T515, R1283, B543) 'CtrlNotifySink7'
    'OKCtrlNotifySink'

    Button - 'OK' (L1203, T515, R1283, B543) 'Button' 'OK' 'OKButton'

    I tried using WindowText(), but got nothing. The dialog appearance
    looks similar attached file. I want to access "File Imported
    correctly" message.

    It cannot be done. The buttons are separate child controls, but the
    icon and the message text are written during WM_PAINT handling. They
    are drawn each time the window is refreshed, and are not child
    windows. There's no way to find the text.

    --
    Tim Roberts,ti...@probo.com <javascript:>
    Providenza & Boekelheide, Inc.

--
You received this message because you are subscribed to the Google
Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to wxpython-users+unsubscribe@googlegroups.com
<mailto:wxpython-users+unsubscribe@googlegroups.com>.
For more options, visit https://groups.google.com/d/optout
<https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Foptout&data=02|01||f23f19e80d1346ea623808d548b03dca|84df9e7fe9f640afb435aaaaaaaaaaaa|1|0|636494844137872814&sdata=7Saxtsf6C0bkBkpKvCrYGU8la%2FTjs41MqodcCs7bL0o%3D&reserved=0&gt;\.

--
Steve (Gadget) Barnes
Any opinions in this message are my personal opinions and do not reflect
those of my employer.

---
This email has been checked for viruses by AVG.

Amrutha Pobbati wrote:

So, would there be any other way to automate it. I am actually trying
to automate a window that pops up this message dialog at one point and
I need to check if it the messagedialog shows info as expected

Yes, we know what you're trying to do. There is certainly no reliable
way to do this. As Steve said, you can grab a snapshot of the dialog as
an image, but that's fraught with problems. The dialog uses whatever
the system font is in the user's current desktop theme, in the
background and foreground colors of the current theme, in a size
determined by the DPI setting. Plus, the dialog and icon layouts change
from version to version.

Are there other ways you can make that determination? Is the "failure"
dialog a different size?

···

--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.