Recommended way of doing a left mouse down, move mouse then left mouse up

Jul 7, 2008 at 5:18 PM
How would you recommend automating a left mouse down action, then mving the mouse, then a left mous up.

I've tried the following:

Core.InputDevices.

Mouse.Instance.Location = new Point(10,10);
System.Threading.Thread.Sleep(125);
Core.InputDevices.
Mouse.LeftDown();
System.Threading.
Thread.Sleep(125);
Core.InputDevices.
Mouse.Instance.Location = new Point(20,20);
System.Threading.
Thread.Sleep(125);
Core.InputDevices.
Mouse.LeftUp();
System.Threading.
Thread.Sleep(125);

But the left up seems to fire twice, any suggestions?

Thanks,

James.

 

Coordinator
Jul 8, 2008 at 6:05 AM
This is the test I ran after launching the WinFormTestApp.

            Window window1 = Desktop.Instance.Windows().Find(delegate(Window window) { return window.Title.Equals("Form1"); });
            window1.Focus();
            Rect bounds = window1.Get<ListBox>("listBoxWithVScrollBar").Bounds;
            System.Windows.Point exteriorEast = C.ImmediateExteriorEast(bounds);
            Mouse.Instance.Location = new Point((int) exteriorEast.X + 3, (int) exteriorEast.Y + 3);
            Mouse.LeftDown();
            Mouse.Instance.Location = new Point((int)exteriorEast.X + 15, (int)exteriorEast.Y + 3);
            Mouse.LeftUp();


To check what mouse events were fired I used Spy++'s LogMessages feature.
Following two messages I got from it:
<00001> 001A04C8 P WM_LBUTTONDOWN fwKeys:MK_LBUTTON xPos:368 yPos:470
<00002> 001A04C8 P WM_LBUTTONUP fwKeys:0000 xPos:380 yPos:470