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

Опубликовано: 04 Октябрь 2024
на канале: JFLHV
5,731
39

How I simulate left and right mouse clicks in Windows apps with C# SendInput function. A download from codeproject.com is used to build functions for LeftClick and RightClick.

InputSender Download:
https://www.codeproject.com/Articles/...

C# Automation Playlist:
   • C# Automation  

private void LeftClick(int x, int y)
{
InputSender.SetCursorPosition(x, y);

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

Thread.Sleep(100);

InputSender.SendMouseInput(new InputSender.MouseInput[]
{
new InputSender.MouseInput
{
dwFlags = (uint)InputSender.MouseEventF.LeftUp
}
});
}