How to move an UI automation element to a different location?

I have a C#.NET app where I am able to find a AutomationElement at a particular point using FromPoint function.

Now I want to manipulate that AutomationElement so that I can move it to a different location, resize it etc.

For moving and resizing , I thought that I can use SetWindowPos Window API function but that requires the handle(an IntPtr) of the target window. Using the AutomationElement's "Current" property, i can read the NativeWindowHandle(an int) of it. Since Control is also a window, I passed this int value as window handle to the SetWindowPost function hoping that it would do my job.

But the code is not working.

Kindly suggest me a way to do this.


What's the type of element you want to move - a top-level window, or an item within a window? Also, is this a type of item that a user could move around using mouse or keyboard? UIAutomation is only supposed to allow you to manipulate the UI consistent with what a regular user could do - you can't use it to move the controls around on a dialog, for example.

The official way to move things in UIAutomation is to see if the element supports the Transform Pattern/a, and then use the Move or Resize methods to move it appropriately. I think this is mostly implemented only on top-level windows, not sure about how widely it is implemented on other controls - you can use UISpy/Inspect to check your target UI.

If the element is a HWND, you could also get the NativeWindowHandle property - which is the underlying HWND, but you'll need to convert it to IntPtr first - and then use it in Win32 APIs. This only works for actual HWND items, though, not for say items in a listview.

Need Your Help

Nokia Qt Mobility: Close Application On click listwidget item

qt nokia

i am new to Nokia Qt Mobility.. and i have just started to develop an Application. My Question is:: How can i close my Application on listwidgets item click...? Thanks..

In Android AsyncTasks run before splash screen displays?

android json multithreading android-asynctask

I have a splash screen that I'm trying to run some AsyncTasks on. It appears the AsyncTasks are running before it shows the splash screen. I need the splash screen to show (logo and each process sh...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.