Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


automate a drag and drop operation

Posted on 2004-10-25
Medium Priority
Last Modified: 2010-04-17
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.  
Question by:sundeep07_er
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 13

Accepted Solution

masterbaker earned 1000 total points
ID: 12407982
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).


Expert Comment

ID: 12412015
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.


Author Comment

ID: 12412430
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Six Sigma Control Plans

598 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question