C# - Simulate mouse drag with SendInput (codeproject implementation) @JFLHV
C# - Simulate mouse drag with SendInput (codeproject implementation)  @JFLHV
Uploaded October 2022 | Updated September 2026, 1 week ago
How I simulate dragging the mouse in other Windows apps using C# SendInput function. A download from codeproject.com is used to build functions to drag the left and right mouse.

InputSender Download:
codeproject.com/Articles/5264831/How-to-Send-Inputs-using-Csharp

C# Automation Playlist:
youtube.com/playlist?list=PLAW4P1Sb_oJbIJIQd8-HPmsVUE6Ez6NFL&si=3rb4bQHNPmHYsaXs

#csharp

private void LeftDrag(Point start, Point end)
{
InputSender.SetCursorPosition(start.X, start.Y);

InputSender.SendMouseInput(new InputSender.MouseInput[]
{
new InputSender.MouseInput
{
dwFlags = (uint)InputSender.MouseEventF.LeftDown

}
});

Thread.Sleep(100);

InputSender.SetCursorPosition(end.X, end.Y);

// added to fix text not always being selected during drag
Thread.Sleep (100);

InputSender.SendMouseInput(new InputSender.MouseInput[]
{
new InputSender.MouseInput
{
dwFlags = (uint)InputSender.MouseEventF.LeftUp
}
});
}
C# - Simulate mouse drag with SendInput (codeproject implementation)Inkscape trim shapeVB.NET - Detect when computer sleeps and wakesGenerate text file of all items in a folder in Windows 10321 countdown green screen with soundBirthday reminders on Google PixelVB.NET - Automate desktop apps with Sendkeys and Win32 functionsVB.NET - Animated passive notification in WinformsC# - WPF .NET app in VS CodeiMovie - Video inside text effect10 basic shapes animated green screenParking spot Google Maps Android
JFLHV |

C# - Simulate mouse drag with SendInput (codeproject implementation)

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER