This script automates an AJAX tree view, using drag & drop. Note that this solution does '''not''' require fixed coordinates, rather it uses the position of certain HTML page element, as returned by the [[!TAGX]] and [[!TAGY]] variables. With this method, iMacros can '''locate (and move) tree elements anywhere on the page'''. The only requirement is that the tree elements are visible in the web browser, so the [[DirectScreen]] command can grab and move them.
<nowiki>
VERSION BUILD=10.4.28.1074
TAB T=1
TAB CLOSEALLOTHERS
URL GOTO=http://demo.imacros.net/Automate/DragDropDemo
SIZE X=1050 Y=750
SET !EXTRACT_TEST_POPUP NO
'select Germany node from treeview and move it to the first position
'Use EXTRACT to avoid to "click" on the element
TAG POS=1 TYPE=A ATTR=TXT:Germany EXTRACT=TXT
DS CMD=LDOWN X={{!TAGX}} Y={{!TAGY}}
WAIT SECONDS=1
'find Europe node and move Germany here
TAG POS=1 TYPE=A ATTR=TXT:Europe EXTRACT=TXT
DS CMD=MOVETO X={{!TAGX}} Y={{!TAGY}}
DS CMD=LUP X={{!TAGX}} Y={{!TAGY}}