Python使用cffi在windows下实现鼠标点击
2016-08-22 本文已影响0人
李二狗2000
import cffi
ffi = cffi.FFI()
ffi.cdef(
"""
//MOUSEEVENTF_LEFTDOWN = 2
//MOUSEEVENTF_LEFTUP = 4
typedef struct Point{
int x;
int y;
}* LPPOINT;
BOOL GetCursorPos(LPPOINT lpPoint);
void mouse_event(
DWORD dwFlags,
DWORD dx,
DWORD dy,
DWORD dwData,
DWORD dwExtraInfo
);
""")
lppoint = ffi.new("struct Point *")
user32 = ffi.dlopen("user32.dll")
user32.GetCursorPos(lppoint)
user32.mouse_event(2, lppoint.x, lppoint.y, 0, 0)
user32.mouse_event(4, lppoint.x, lppoint.y, 0, 0)