Drag and drop automation

A drag and drop automation should never be used as it's mouse coordinates dependant. We give the script below only as an example when no other way is possible than Drag and Drop method. The script works under XP (window names are different under Vista/Windows 7).

You can find the corresponding script file under Script_Examples, sub-directory of scripts.

 

'This small example shows a drag and drop automation in Explorer under XP,

'from the right pane to the left pane.

'Use Recording mode, Low level, to record mouse coordinates for the object you drag

'and the place where to drop.

'Then keep only the necessary mouse moves and add the second UseWindow as explained below.

Shell("explorer.exe")

UseWindow("EXPLORER.EXE|SysListView32|My documents|1",1, NoActivate)

'A click down on one item.

ClickMouse(Left,Down,47,81)

'We start to move it.

MoveMouse(47,81)

MoveMouse(43,80)

MoveMouse(39,79)

 

'As we move it in another window (the left one), the window name changes, so there is a new UseWindow.

usewindow("EXPLORER.EXE|SysTreeView32|My documents|1",1,Noactivate)

MoveMouse(40,58)

MoveMouse(40,59)

MoveMouse(27,57)

pause 2

'A click up for finishing the drop.

ClickMouse(Left,Up,27,57)