[IronPython] IronPython and C# not giving the same result
Lepisto, Stephen P
stephen.p.lepisto at intel.com
Wed Jun 16 17:08:39 CEST 2010
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<http://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<http://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<http://rae.Current.Name> == 'Untitled - Notepad':
print '-'*24
ae = swu.TreeWalker.ControlViewWalker.GetFirstChild( rae )
while ae:
print ae.Current.Name<http://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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20100616/b99c760e/attachment.html>
More information about the Ironpython-users
mailing list