Btw you should specify what environment you're working in and make your code a bit more detailed. Using SendInput is one option, I don't know what you're trying to do exactly, but I'll give you two more options to try for simulating clicks. Something like this would works fine (I code in python but it should be the same idea):
def leftClick(x=0, y=0):
win32api.SetCursorPos((x,y)) #set the cursor to where you wanna click
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, x, y, 0, 0) #generate a mouse event
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, x, y, 0, 0)
return True
def doubleClick(x=0, y=0):
leftClick(x,y)
leftClick(x,y)
You could sleep for 50 ms in between time.sleep(0.05) but it works for me without it and I've tested in a vm.
Another option if you want to perform silent clicks without having to move the cursor, you can send a message to the window where you want to click knowing the window handle (hwnd), here I assume you pass the handle as a parameter.
def leftClick(x=0, y=0, hwnd):
lParam = win32api.MAKELONG(x,y) # create a c long type to hold your click coordinates
win32gui.SendMessage(hwnd, win32con.WM_LBUTTONDOWN, win32con.MK_LBUTTON, lparam) # send a message to the window that the mouse left button is down.
win32gui.SendMessage(hwnd, win32con.WM_LBUTTONUP, 0, lparam) # send a message to the window that the mouse left button is up.
return True
def doubleClick(x=0, y=0, hwnd):
leftClick(x,y, hwnd)
leftClick(x,y, hwnd)
or you can send the message WM_LBUTTONDBLCLK up to you.