Soledad Pano's Blog

Just Technical Stuff

UI Automation Article Published on Level Extreme

On this month's edition of the Level Extreme .Net Magazine, my article about Building an UI Automation Client Application was published. The article walks through building a client application for automating a win 32 target application (the Windows Address Book). The idea is to show through simple code snippets how to use the UI Automation API for manipulating a target application programmatically through its UI. It shows how to find the UI elements, and how to work with the UI Automation patterns and handle events. The sample client application code contains further examples and can be downloaded from the article's page. Hope you read it!

March edition Level Extreme 

Read more on the magazine from Martin Salias.

Posted: Mar 12 2008, 03:38 PM by spano | with 10 comment(s)
Filed under:

Comments

MarkJoel60 said:

Hi Soledad,

When I try to run your sample application in Visual Studio 2008, it throws an exception:

"Cross-thread operation not valid: Control 'btnGetNameTxt' accessed from a thread other than the thread it was created on."

on Line 295:     btnGetNameTxt.Enabled = enable;

Any idea why?

# July 18, 2008 8:22 AM

spano said:

Hi Mark, I didn't try it on VS2008. I'll try to run it and see what happens.

# July 18, 2008 9:13 AM

MarkJoel60 said:

Soledad,

Did you have any luck? I was wondering if [Regions] are maybe seen as threads? I don't know... was wondering if you had a chance to look at it...?

# July 20, 2008 6:56 PM

spano said:

I opened the solution with VS2008. When running against framework 2.0 it works. When running against 3.5 sometimes (not always) it throws the error in the menu automation. Evidently something had changed, but I didn't have enought time to figure it out yet.

# July 21, 2008 6:53 PM

MarkJoel60 said:

Hmmm that's strange. I am running 3.5, and I get a very consitent error. Whenever I subscribe to the Properties button event, and I click that button, I will get the thread error every time...

# July 21, 2008 9:35 PM

spano said:

Which OS are you running on? I'm in XP

# July 21, 2008 9:57 PM

MarkJoel60 said:

I Windows XP Professional, Service Pack 2.

So, you are able to subscribe to the properties button event in .NET 3.5 and you never have a problem?

# July 22, 2008 3:23 PM

spano said:

Yes, I don't have problems with the properties button. Only some times with the menu item.

# July 22, 2008 6:20 PM

arachnode.net said:

Check the InvokeRequired property and call the offending method with a BeginInvoke/delegate.

# August 19, 2008 3:05 PM

de_bug said:

I had this error:

"Cross-thread operation not valid: Control 'btnGetNameTxt' accessed from a thread other than the thread it was created on."

This was because I was running the application on a xp 64bit OS.

To solve simply change the Target Cpu to x86 in the advanced compile options.

# January 22, 2009 10:55 AM
Leave a Comment

(required) 

(required) 

(optional)

(required)