我试图澄清win32api。我只是做了一个简单的例子。获取记事本窗口,将鼠标移动到一个位置,单击并写入一个字符串。但它不起作用。有什么问题?
有人可以为我澄清 lParam 参数是什么吗?
它有什么作用,它是什么类型,它应该看起来如何?
import win32api, win32con, win32gui, win32ui, win32service, os, time
def f_click(pycwnd):
x=300
y=300
lParam = y <<15 | x
pycwnd.SendMessage(win32con.WM_LBUTTONDOWN, win32con.MK_LBUTTON, lParam);
pycwnd.SendMessage(win32con.WM_LBUTTONUP, 0, lParam);
def get_whndl():
whndl = win32gui.FindWindowEx(0, 0, None, 'NB.txt - Notepad')
return whndl
def make_pycwnd(hwnd):
PyCWnd = win32ui.CreateWindowFromHandle(hwnd)
return PyCWnd
def send_input_hax(pycwnd, msg):
f_click(pycwnd)
for c in msg:
if c == "\n":
pycwnd.SendMessage(win32con.WM_KEYDOWN, win32con.VK_RETURN, 0)
pycwnd.SendMessage(win32con.WM_KEYUP, win32con.VK_RETURN, 0)
else:
pycwnd.SendMessage(win32con.WM_CHAR, ord(c), 0)
pycwnd.UpdateWindow()
whndl = get_whndl()
pycwnd = make_pycwnd(whndl)
msg = "It works !\n"
send_input_hax(pycwnd,msg)