Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ internal class InternalNativeMethods
public const int KEYEVENTF_UNICODE = 0x0004;
public const int KEYEVENTF_SCANCODE = 0x0008;

public const int MOUSEEVENTF_MOVE_NOCOALESCE = 0x2000;
public const int MOUSEEVENTF_VIRTUALDESK = 0x4000;

public const int INPUT_MOUSE = 0;
Expand Down Expand Up @@ -483,6 +484,12 @@ public static void SendMouseInput( double x, double y, int data, SendMouseInputF

intflags |= InternalNativeMethods.MOUSEEVENTF_VIRTUALDESK;
}

// don't coalesce mouse moves - tests expect to see the results immediately
if ((intflags & (int)SendMouseInputFlags.Move) != 0)
{
intflags |= InternalNativeMethods.MOUSEEVENTF_MOVE_NOCOALESCE;
}

InternalUnsafeNativeMethods.INPUT mi = new InternalUnsafeNativeMethods.INPUT();
mi.type = InternalNativeMethods.INPUT_MOUSE;
Expand All @@ -495,6 +502,14 @@ public static void SendMouseInput( double x, double y, int data, SendMouseInputF
//Console.WriteLine("Sending");
if ( InternalUnsafeNativeMethods.SendInput( 1, ref mi, Marshal.SizeOf( mi ) ) == 0 )
throw new Win32Exception( Marshal.GetLastWin32Error() );

if ((intflags & (int)SendMouseInputFlags.Wheel) != 0)
{
// MouseWheel input seems to be getting coalesced by the OS, similar to mouse-move.
// There isn't a NOCOALESCE flag to turn this off, so instead just sleep for
// a short time, hopefully enough to avoid the coalescing.
System.Threading.Thread.Sleep(50);
}
}


Expand Down