python/win32: post a click event to a window? -


I want to simulate a mouse click on a window, but I want to post click directly to the window event (not a normal mouse click using by win32api.mouse_event simulation (win32con.MOUSEEVENTF_LEFTDOWN, 0, 0) ). What is the proper way to do this? I have tried the following, but there is no effect in this:

  DEF MacLong (low, high): low returns. (High & lt; & lt; 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 right handle for the window In this case I was trying to activate the file menu.

If window is the owner of the Window menu, The WM_LBUTTONDOWN window will not work for the customer area, and the menu area is non-customer. I have not tested this, but you might try posting WM_NCLBUTTONDOWN > Instead, HTMENU , and With mouse position

Another option should be to use only GetSubMenu and TrackPopupMenu . The only problem with this is that if you want to enable the user to navigate through the other sub-menus.


Comments