Retrieve content inside MessageDialog using pywinauto

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Retrieve content inside MessageDialog using pywinauto

Amrutha Pobbati

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.

--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.

Capture2.PNG (20K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Retrieve content inside MessageDialog using pywinauto

Tim Roberts
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, [hidden email]
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Retrieve content inside MessageDialog using pywinauto

Amrutha Pobbati
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:
<a href="https://stackoverflow.com/questions/47914863/how-to-automate-content-inside-messagedialog-using-pywinauto#" title="Click to mark as favorite question (click again to undo)" style="margin-right:auto;margin-bottom:2px;margin-left:auto;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:1px;line-height:inherit;font-family:inherit;vertical-align:baseline;color:rgb(0,119,204);background-image:url(&quot;img/sprites.svg?v=1b3cdae197be&quot;),none;background-repeat:no-repeat;overflow:hidden;display:block;width:40px;min-height:30px;background-position:0px -120px" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fstackoverflow.com%2Fquestions%2F47914863%2Fhow-to-automate-content-inside-messagedialog-using-pywinauto%23\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEJUErOgvIufRxDSzT02se_e3uL0w&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fstackoverflow.com%2Fquestions%2F47914863%2Fhow-to-automate-content-inside-messagedialog-using-pywinauto%23\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEJUErOgvIufRxDSzT02se_e3uL0w&#39;;return true;">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, <a href="javascript:" target="_blank" gdf-obfuscated-mailto="R3SHpVJwCAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">ti...@...
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Retrieve content inside MessageDialog using pywinauto

GadgetSteve
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%7C01%7C%7Cf23f19e80d1346ea623808d548b03dca%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636494844137872814&sdata=lmKrMSNVsxyHg8zCMTw%2FLanqtRc6fZHmTuxYgebrREI%3D&reserved=0>
>>
>>
>>    
>>
>>     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,[hidden email] <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 [hidden email]
> <mailto:[hidden email]>.
> 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%7C01%7C%7Cf23f19e80d1346ea623808d548b03dca%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636494844137872814&sdata=7Saxtsf6C0bkBkpKvCrYGU8la%2FTjs41MqodcCs7bL0o%3D&reserved=0>.

--
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.
http://www.avg.com

--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Retrieve content inside MessageDialog using pywinauto

Tim Roberts
In reply to this post by Amrutha Pobbati
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, [hidden email]
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.