[IronPython] IronPython and C# not giving the same result

yngipy hernan yngipy at gmail.com
Thu Jun 17 21:59:47 PDT 2010


First off, Notepad was running with the word "test1". Sorry for not being
clear.

As with Wolfram, I also used UI Spy. UI Spy would see tree element from the
"Notepad" window. Namely:
Edit control (this contains "test1" text)
TitlebarControrl (this is where the min, max, close, system menu is
contained. And it has the text "Untitled - Notepad")
Application Menu bar (This is the main menus).

So yes, IronPython does not seem to like UI Automation much. C# can do it
just fine by the way.

This might be related to this
issue<http://blogs.msdn.com/b/shrib/archive/2008/03/24/ironpython-cannot-call-automationelement-fromhandle.aspx>.
I am hoping that people with deep enough knowledge about IronPython can
confirm this.

Or if I can get enough direction, I can spend some time digging into it....
but I need hint how to go from here.

Regards,
Yngipy


2010/6/17 Stanger, Wolfram <Wolfram.Stanger at kratzer-automation.com>

>  Hello all,
>
> unless we get following child elements for example in a empty notepad
> application all playing be be useless:
>
> Raw View:
> ---------------
>   "Window" "Unbenannt - Editor"
>     "Document" ""
>       "Scrollbar" "Vertikale Bildlaufleiste"
>         "Button" "Zurück um kleine Menge"
>         "Button" "Vorwärts um kleine Menge"
>     "Titelbar" "Unbenannt - Editor"
>       "Menubar" "Systemmenüleiste"
>         "Menuitem" "System"
>       "Button" "Minimieren"
>       "Button" "Maximieren"
>       "Button" "Schließen"
>     "Menubar" "Anwendung"
>       "Menuitem" "Datei"
>       "Menuitem" "Bearbeiten"
>       "Menuitem" "Format"
>       "Menuitem" "Ansicht"
>       "Menuitem" "?"
> It a german window a I have translated the ControlType (1st word; 2nd =
> name) to english.
>
> The output ist created from the tool UISpy, witch shows all
> AutomationElements from all application curently running as child beneath
> the 'desktop' window.
>
> UISpy come from MS and can be downloaded free.
>
> Greetings
> Wolfram
>
>  ------------------------------
> *Von:* users-bounces at lists.ironpython.com [mailto:
> users-bounces at lists.ironpython.com] *Im Auftrag von *Lukas Cenovsky
> *Gesendet:* Donnerstag, 17. Juni 2010 10:52
> *An:* Discussion of IronPython
> *Betreff:* Re: [IronPython] IronPython and C# not giving the same result
>
> I tried your IronPython script and it found one child element which name is
> ''.
>
> Change the print line to:
> print 'Name:',  ae.Current.Name
>
> --
> -- Lukáš
>
>
> yngipy hernan wrote:
>
> Hi,
>
> All root elements are ok. Thus say, i can see all (?) of the root elements.
>
> But not when trying to iterate child elements of the Notepad automation
> element.
>
> My Info:
> W7 32 bit (UAC disabled)
> .Net 4.0
>
> On Wed, Jun 16, 2010 at 10:08 AM, Lepisto, Stephen P <
> stephen.p.lepisto at intel.com> wrote:
>
>>  I was able to successfully run that python code under both IronPython
>> 2.0.3 and IronPython 2.6.1 and it produced a list of all top-level
>> applications.  I modified the one line
>>
>>
>>
>> if rae.Current.Name == 'Untitled - Notepad':
>>
>>
>>
>> to be
>>
>>
>>
>> if not rae.Current.Name == '':
>>
>>
>>
>> just to see what was actually being found.
>>
>>
>>
>> Note: I'm running Windows XP SP3.
>>
>>
>>
>> *From:* users-bounces at lists.ironpython.com [mailto:
>> users-bounces at lists.ironpython.com] *On Behalf Of *yngipy hernan
>> *Sent:* Tuesday, June 15, 2010 10:09 PM
>> *To:* Discussion of IronPython
>> *Subject:* [IronPython] IronPython and C# not giving the same result
>>
>>
>>
>> Hi All,
>>
>>
>>
>> I have tried to transliterate the following C# code to IronPython:
>>
>>
>>
>> using System;
>>
>> using System.Collections.Generic;
>>
>> using System.Linq;
>>
>> using System.Text;
>>
>> using System.Windows.Automation;
>>
>>
>>
>> namespace ConsoleApplication1
>>
>> {
>>
>>     class Program
>>
>>     {
>>
>>         static void Main(string[] args)
>>
>>         {
>>
>>             AutomationElement eNode;
>>
>>             eNode =
>> TreeWalker.ControlViewWalker.GetFirstChild(AutomationElement.RootElement);
>>
>>             while(eNode != null) {
>>
>>                 if (eNode.Current.Name == "Untitled - Notepad")
>>
>>                 {
>>
>>                     AutomationElement ae;
>>
>>                     ae =
>> TreeWalker.ControlViewWalker.GetFirstChild(eNode);
>>
>>                     System.Console.WriteLine("-------------------");
>>
>>                     while (ae != null)
>>
>>                     {
>>
>>                         System.Console.WriteLine("Name: {0}",
>> ae.Current.Name);
>>
>>                         ae = TreeWalker.ControlViewWalker.GetNextSibling(
>> ae);
>>
>>                     }
>>
>>                     System.Console.WriteLine("-------------------");
>>
>>                 }
>>
>>                 eNode =
>> TreeWalker.ControlViewWalker.GetNextSibling(eNode);
>>
>>             }
>>
>>         }
>>
>>     }
>>
>> }
>>
>>
>>
>> The output of this program looks like:
>>
>>
>>
>> -------------------
>>
>> Name: test1
>>
>> Name: Untitled - Notepad
>>
>> Name: Application
>>
>> -------------------
>>
>>
>>
>> This is my IronPython code:
>>
>>
>>
>> import clr
>>
>>
>>
>> clr.AddReference('UIAutomationTypes')
>>
>> clr.AddReference('UIAutomationProvider')
>>
>> clr.AddReference('UIAutomationClient')
>>
>>
>>
>> import System.Windows.Automation as swu
>>
>>
>>
>> rae = swu.TreeWalker.ControlViewWalker.GetFirstChild(
>> swu.AutomationElement.RootElement )
>>
>> while rae:
>>
>>     if rae.Current.Name == 'Untitled - Notepad':
>>
>>         print '-'*24
>>
>>         ae = swu.TreeWalker.ControlViewWalker.GetFirstChild( rae )
>>
>>         while ae:
>>
>>             print ae.Current.Name
>>
>>             ae = swu.TreeWalker.ControlViewWalker.GetNextSibling( ae )
>>
>>         print '-'*24
>>
>>     rae = swu.TreeWalker.ControlViewWalker.GetNextSibling( rae )
>>
>>
>>
>> The output of this shows:
>>
>> ------------------------
>>
>> test1
>>
>> ------------------------
>>
>>
>>
>> I read somewhere that IronPython used to have issues with UI Automation.
>> Is still the case?
>>
>>
>>
>> Regards,
>>
>> Yngipy
>>
>> _______________________________________________
>> Users mailing list
>> Users at lists.ironpython.com
>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>>
>>
> ------------------------------
>
> _______________________________________________
> Users mailing listUsers at lists.ironpython.comhttp://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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ironpython.com/pipermail/users-ironpython.com/attachments/20100617/bcae8dca/attachment.htm>


More information about the Users mailing list