spcharc
2020-07-08 20:39:48 +08:00
花一个小时现撸了个 python 脚本:
import ctypes
class MouseInput(ctypes.Structure):
_fields_ = [('a', ctypes.c_int32),
('b', ctypes.c_int32),
('c', ctypes.c_uint32),
('d', ctypes.c_uint32),
('e', ctypes.c_uint32),
('f', ctypes.c_void_p)]
class Input(ctypes.Structure):
_fields_ = [('a', ctypes.c_uint32),
('b', MouseInput)]
input_data1 = Input(0, MouseInput(0, 0, 0, 0x2, 0,
ctypes.cast(ctypes.byref(ctypes.c_uint32(0)), ctypes.c_void_p)))
input_data2 = Input(0, MouseInput(0, 0, 0, 0x4, 0,
ctypes.cast(ctypes.byref(ctypes.c_uint32(0)), ctypes.c_void_p)))
func = ctypes.windll.user32.SendInput
func.argtypes = ctypes.c_uint32, Input, ctypes.c_int32
func.restype = ctypes.c_uint32
def click():
assert(func(1, input_data1, ctypes.sizeof(Input)) == 1)
assert(func(1, input_data2, ctypes.sizeof(Input)) == 1)
走的是 user32.dll 。调用 click()函数就能在你当前鼠标位置上按一下鼠标左键。