With reference to my earlier posts on drag and drop, here are few more methods. You will need to have WindowsInput module,posted in earlier posts, along with below.
def drag_drop_on(target, src_offset=0, dst_offset=0)
assert_target target
drop_x = target.left_edge_absolute + dst_offset
drop_y = target.top_edge_absolute + dst_offset
drag_to(drop_x, drop_y, src_offset)
end
def drag_drop(target, src_offset=1, dst_offset=1)
drag_x = left_edge_absolute + src_offset
drag_y = top_edge_absolute + src_offset
drop_x = target.left_edge_absolute + dst_offset
drop_y = target.top_edge_absolute + dst_offset
WindowsInput.move_mouse(drag_x, drag_y)
WindowsInput.left_down
WindowsInput.move_mouse(drop_x, drop_y)
WindowsInput.left_up
end
def drag_drop_distance(distance_x, distance_y, src_offset=0, dst_offset=0)
drag_x, drag_y = source_x_y(src_offset)
drop_x = drag_x + distance_x + dst_offset
drop_y = drag_y + distance_y + dst_offset
drag_to(drop_x, drop_y, src_offset)
end
def drag_drop_at(drop_x, drop_y, src_offset=0)
drag_to(drop_x, drop_y, src_offset)
end
def drag_drop_below(target, src_offset=0, dst_offset=0)
assert_target target
drop_x = target.left_edge_absolute + dst_offset
drop_y = target.bottom_edge_absolute + 2 + dst_offset
drag_to(drop_x, drop_y, src_offset)
end
def drag_drop_above(target, src_offset=0, dst_offset=0)
assert_target target
drop_x = target.left_edge_absolute + dst_offset
drop_y = target.top_edge_absolute - 2 + dst_offset
drag_to(drop_x, drop_y, src_offset)
end
def drag_to(drop_x, drop_y, src_offset)
drag_x, drag_y = source_x_y(src_offset)
WindowsInput.move_mouse(drag_x, drag_y)
WindowsInput.left_down
WindowsInput.move_mouse(drop_x, drop_y)
WindowsInput.left_up
end