[IronPython] [python] Re: Getting window properties

Srivatsn N srivatsn at microsoft.com
Wed Jan 9 19:18:56 CET 2008


The pop-up window might be one level below the top-level in the UI tree. You can use UISpy (http://msdn2.microsoft.com/en-us/library/ms727247.aspx) to inspect the UI Tree hierarchy for UIAutomation and also the properties that are exposed. The text in the popup should also be exposed - generally through the value property (you can verify that in UISpy). You should have the tool installed if you have the SDK.

Srivatsn

-----Original Message-----
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Marcus Patino Pan
Sent: Wednesday, January 09, 2008 2:56 AM
To: Discussion of IronPython
Subject: Re: [IronPython] [python] Re: Getting window properties

Im back!!!

What do I need to change in the example to get the active window?? Im
using an example where word is opened and then the document is wrote in
then is attempted to be saved. The example below finds the parent window
"Document1 - Mircosoft Word" but wont find the pop up window asking if
you would like to save the document.


Any ideas?

Also if there is a way of retrieving the text in the pop up box that
would be amazing. I'll continue playing with it to see what I can find
out.

Many Thanks

Marcus

-----Original Message-----
From: users-bounces at lists.ironpython.com
[mailto:users-bounces at lists.ironpython.com] On Behalf Of Marcus Patino
Pan
Sent: 09 January 2008 09:56
To: Discussion of IronPython
Subject: Re: [IronPython] [python] Re: Getting window properties

That's brilliant!! Thanks everyone for your help.

I'll probably be back for more advice soon.


Marcus




-----Original Message-----
From: users-bounces at lists.ironpython.com
[mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord
Sent: 08 January 2008 19:17
To: Discussion of IronPython
Subject: Re: [IronPython] [python] Re: Getting window properties

Jim Hugunin wrote:
> Another option would be to use the System.Windows.Automation library -
new in .NET 3.0.  It's a lot easier to use than the native APIs when it
works for you.  This sample will print the titles of all the top-level
windows.
>
> --------------------------------------
> import clr
> clr.AddReference('UIAutomationClient')
> clr.AddReference('UIAutomationTypes')
> from System.Windows.Automation import *
>
> tops = AutomationElement.RootElement.FindAll(TreeScope.Children,
Condition.TrueCondition)
> for elem in tops:
>     print elem.GetCurrentPropertyValue(AutomationElement.NameProperty)
>

Wow - I didn't know there was an automation library in .NET 3!

Thanks

Michael

> ----------------------------------------
>
> Thanks - Jim
>
> -----Original Message-----
> From: users-bounces at lists.ironpython.com
[mailto:users-bounces at lists.ironpython.com] On Behalf Of Fuzzyman
> Sent: Tuesday, January 08, 2008 2:34 AM
> To: Discussion of IronPython
> Subject: Re: [IronPython] Getting window properties
>
> Marcus Patino Pan wrote:
>
>
>> Hello,
>>
>> I wondered if you could help me. I have IronPython working fine, but
>> what I would like to do is use it to test another application. I have
>> worked out how to use sendkeys but to do proper testing I need to be
>> able to check if the correct window has appeared on screen, so need
to
>> check some of its properties, like its title. I've been looking on
the
>> internet for examples but with no luck.
>>
>> Could someone point me in the right direction?
>>
>>
>
> We do a bit of this at Resolver, but mainly do 'in process' testing
> where we have access to the forms as .NET objects.
>
> The functions you want live mainly in User32.dll, which is unmanaged
> code. There are functions like GetForegroundWindow, which returns a
> window handle. From this you can determine the title of the window
etc.
> You can also send mouse moves and button clicks, so it is possible to
> interact with applications in a completely 'black-box' manner.
>
> Unfortunately, although some parts of this are straightforward, we had
> real problems when trying to do things like interact with menus
> (particularly context menus) using this technique.
>
> The bad news is that because these functions live in unmanaged code,
you
> need attributes to work with them. We have some stub C# at Resolver
that
> exposes those functions to IronPython. *However*, I recently
discovered
> Seo's implementation of ctypes for IronPython (part of FePy but should
> work fine with a standard build of IronPython). This allows you to do
> 'dynamic platform invoke', meaning you can call these functions from
> straight IronPython!
>
> There is a minimal example at:
>
http://www.ironpython.info/index.php/Access_Unmanaged_Code_with_Dynamic_
P/Invoke
>
> I hope this is helpful.
>
> Michael Foord
> http://www.manning.com/foord
>
>
>
>> Many Thanks
>>
>> Marcus
>>
>> This email and any files transmitted with it are confidential and
>> intended solely for the use of the individual or entity to whom they
>> are addressed ("the addressee"). If you have received this email in
>> error please notify the system manager at System C Healthcare plc.
>> This email and its attachments (if any) contain(s) confidential
>> information the property of System C Healthcare plc and is/are
>> intended only for the addressee. If you are not the addressee you
>> should not use, disseminate, distribute or copy this e-mail or any
>> attachment.
>>
>> System C Healthcare plc, Registered Office, Brenchley House, Week
>> Street, Maidstone, Kent ME14 1RF Registered in England no: 1754990
>>
>>
------------------------------------------------------------------------
>>
>> _______________________________________________
>> Users mailing list
>> Users at lists.ironpython.com
>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>>
>>
>>
>
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
>

_______________________________________________
Users mailing list
Users at lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they are
addressed ("the addressee"). If you have received this email in error
please notify the system manager at System C Healthcare plc. This email
and its attachments (if any) contain(s) confidential information the
property of System C Healthcare plc and is/are intended only for the
addressee. If you are not the addressee you should not use, disseminate,
distribute or copy this e-mail or any attachment.

System C Healthcare plc, Registered Office, Brenchley House, Week
Street, Maidstone, Kent ME14 1RF Registered in England no: 1754990
_______________________________________________
Users mailing list
Users at lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed ("the addressee"). If you have received this email in error please notify the system manager at System C Healthcare plc. This email and its attachments (if any) contain(s) confidential information the property of System C Healthcare plc and is/are intended only for the addressee. If you are not the addressee you should not use, disseminate, distribute or copy this e-mail or any attachment.

System C Healthcare plc, Registered Office, Brenchley House, Week Street, Maidstone, Kent ME14 1RF Registered in England no: 1754990
_______________________________________________
Users mailing list
Users at lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com



More information about the Ironpython-users mailing list