Reputation: 11
I try to simulate mouse drag operation by win32api.SendMessage
in Python,
here is my code:
import win32api
...
lParam_start = win32api.MAKELONG(start[0], start[1])
lParam_end = win32api.MAKELONG(end[0] , end[1])
win32api.SendMessage(self.window.handle, win32con.WM_LBUTTONDOWN, win32con.MK_LBUTTON, lParam_start)
time.sleep(0.1)
win32api.SendMessage(self.window.handle, win32con.WM_MOUSEMOVE, win32con.MK_LBUTTON, lParam_end)
time.sleep(0.1)
win32gui.SendMessage(self.window.handle, win32con.WM_LBUTTONUP, 0, lParam_end)
...
and Spy++ log message:
The actual situation seems to be that the mouse is not in LBUTTONDOWN
state during movement.
I have tried replacing WM_LBUTTONUP
with WM_MOUSELEAVE
, still the same.
How to keep the LBUTTONDOWN
state in WM_MOUSEMOVE
? I know SendInput()
is ok, but it can only be used in foreground mode.
Upvotes: 0
Views: 185