automate a drag and drop operation

hi experts,
Pls help. I want to automate a the process of dragging a particular treeview item and drop it on another treeview control (both treeview controls are child windows of   another application running on win2000) .I

I tried by sending mouse  (WM_)mouse  messages to mimic the clicking of a treeview node and wm_lbuttonup message to the target treeview  but nothing worked.

I understand that in the other application the first treeview control is capturing the mouse when ever a mouse is held down .(found using the spy++)
But i have no idea ,as how to force a window in another application to capture the mouse and make it believe that an actual dragging operation is underway.

pls help.  
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Have you ever heard of a program called AutoIT?  Here's a link:

It is a great freeware scripting tool.  Yes, it can do mouse movements and clicks too (I assume this includes dragging and dropping).


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Take a look at this knowledge base article:

It describes dragging and dropping between two treenodes.

Your target window doesn't need to know about the mouse click on the source window. Drag and drop is an OLE function. When you start a drag operation, you are really just copying or cutting some text from one control. When you drop the dragged item in the target control, you are really just handling the text that was dragged from the source control.

Hope that helps.

sundeep07_erAuthor Commented:
Hi experts , Tnx for the response.I think I have not made my question clear.
I am working on a mini projet which will automate many of my daily work.

we have at our office a big application on whcih I work.Many of the work is monotonous and booring.So I wanted to automate all of the tasks,

When ever I used any automation kind of software I simulats the mouse clicks and key strokes so, here my target application must receive focus all the time when the automation software is running.
To avoid this I retreived the window handles of several text box and other windos and sent appropiate messages .With this my terget app. need not be the window having the focus.I can have it minimised and I can work on other job while my own software is doing the job of automation.

Now, the problem here is that I have to drag and drop a particular item (depending upon certain conditions) and drop it on a treeviw control.

I want to drag and drop even while the window is minimised.Just like I am able to simulate keystrokes by sending messages (even while the window is minimised) I want to perform the drag and drop operation even while the window is minimised.
I strongly believe that it can be done .but how?
Pls help.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.