• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 348
  • Last Modified:

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.  
  • 2
1 Solution
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).

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.


Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now