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.

10 Comments

  • 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?

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

  • 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...?

  • 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.

  • 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...

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

  • 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?

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

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

  • 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.

Comments have been disabled for this content.