I'm having trouble dragging a control to another control. I've had success in being able to select both controls but when I try to use:
Mouse.Instance.Location = dragControl.ClickablePoint;
Mouse.LeftDown();
Mouse.Instance.Location = dropControl.ClickablePoint;
Mouse.LeftUp();
The drag doesn't happen, the mouse moves. But the control stays in the initial spot.
I've also tried using:
Mouse.Instance.DragAndDrop(dragItem, dragItem.ClickablePoint, dropItem, dropItem.ClickablePoint);
Still no luck.
I was doing some experimentation and one point and got it to work, but I've lost track of the resource I found a workable solution in before (and I deleted my working code - lesson learned).
Any help would be appreciated!
Thanks in advance!
Update 6/15
Okay, so I've been hacking away at this some more. For some reason it seems like the control isn't actually being dragged. The mouse is moving, but the control isn't being moved with it.
Alright, I have no idea why White DragAndDrop functionality isn't working (or manually using leftDown, move, leftUp).
But I did find a solution.
Essentially I re-wrote the white drag and drop function with a delay between each step. So it looks like the following:
guiObject.Click();
Mouse.LeftDown();
var stepCount = 10;
var stepAmount = (float) (guiObject.ClickablePoint.Y - targetObject.ClickablePoint.Y)/stepCount;
for (var i = 0; i < stepCount; i++)
{
Mouse.Instance.Location = new Point(Mouse.Instance.Location.X, Mouse.Instance.Location.Y - stepAmount);
Thread.Sleep(75); // I played around with the values and 75 seems to work without being too slow
}
Mouse.LeftUp();
Hopefully this will help anyone else that might be having this problem. I don't know why I needed to force a delay, but it works.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With