Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > Avalon

AutomationElement from Window hangs on AutomationElement.Current

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 02-24-2006   #1 (permalink)
Peter Fitzgibbons
Guest


 

AutomationElement from Window hangs on AutomationElement.Current

Hello all,

I am using NUnit to unit test a WPF form. Issues with Nunit MTA threads and
WPF STA Thread requirement have been handled. The NUnit thread now correctly
receives any Assert exceptions from the delegated STA Thread running the WPF
window.

I am also instantiating AutomationElement in order to automate the window
for testing.

AutomationElement instance is hanging on Current property-get. I can
step-through the TestAddressbookWorker() method below and teh debugger (and
run-time out of debug mode) hangs at "x =
aeWindow.Current.BoundingRectangle.Location.X;"
In the CommandWindow-Immediate, inspection of abHelper results in "Function
evaluation timed out." on the AcceleratorKey property and then "Function
evaluation disabled..." on every subsequent property.

I notice that the handle reported by "abHelper.Handle" is not the same as
that reported on teh window by Spy++ during the debug session. I know that
Spy++ is reporting Hex and Handle property is reporting IntPtr integer. The
values from one debug session are :
Spy++ : HxF09CE = 985550
abHelper.Handle : Hx8098A = 526730

I noticed in the WinFX Sample "InvokePattern and ExpandCollapsePattern Menu
Item Sample " that the target window for automation is Win32 and in fact an
instance of Notepad.exe. So I am very curious how to reconcile the sample
with a pure-WinFX example that is calling only XAML windows.

Thank you for your assistance and time investigating tthis one!

using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Windows;
using System.Windows.Automation;
using System.Windows.Interop;
using NUnit.Framework;

namespace NunitTest
{
[TestFixture]
public class Class1
{
NUnitHelpers.CrossThreadTestRunner runner = new
NUnitHelpers.CrossThreadTestRunner();

[Test]
public void truthtest()
{
Assert.IsTrue(true);
}

[Test]
public void falsetest()
{
Assert.IsTrue(false);
}

public static void TestAddressbookWorker()
{
Window ab = new AddressBookLib.Window1();
try
{
ab.Show();

WindowInteropHelper abHelper = new WindowInteropHelper(ab);
IntPtr abHwnd = abHelper.Handle;
AutomationElement aeWindow =
AutomationElement.FromHandle(abHwnd);

double x = -1d;
x = aeWindow.Current.BoundingRectangle.Location.X;
Assert.AreEqual(0, x);
}
finally
{
ab.Close();
ab = null;

}

}

[Test]
public void TestAddressBook()
{
runner.RunSTA(new ThreadStart(TestAddressbookWorker));
}

}
}


My System SpecsSystem Spec
Closed Thread

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I keep the current window on top as new one loads? mattfbuelow Network & Internet 6 3 Weeks Ago 01:34 PM
VS2005 Basic Hangs when changing from Code window to Design Window ngrTerry .NET General 0 07-30-2008 06:56 AM
rundll code to close current window ldvg General Discussion 2 07-11-2008 05:17 PM
Updating window title bar to current location Marc Scheuner PowerShell 2 12-30-2007 03:42 PM
Vista - ? Mark - Current window Help Rox Vista General 6 08-21-2007 06:19 AM


Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51