I want to simulate a mouse click on a window, but I want to post the click event directly to the window (not by simulating a general mouse click using win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0)
). What's the proper way to do it? I've tried the following, but it doesn't seem to have an effect:
def MAKELONG(low, high):
return low | (high << 16)
win32gui.PostMessage(window,
win32con.WM_LBUTTONDOWN,
win32con.MK_LBUTTON,
MAKELONG(21,42))
time.sleep(0.05)
win32gui.PostMessage(window,
win32con.WM_LBUTTONUP,
0,
MAKELONG(21,42))
window
is the correct handle for the window. In this case I was trying to get the file menu to activate.