Python写的点击
import win32api
import win32con
import time
import pyautogui as pag
state_left = win32api.GetKeyState(0x01) # Left button down = 0 or 1. Button up = -127 or -128
state_right = win32api.GetKeyState(0x02) # Right button down = 0 or 1. Button up = -127 or -128
while True:
a = win32api.GetKeyState(0x01)
b = win32api.GetKeyState(0x02)
if a != state_left: # Button state changed
state_left = a
print(a)
if a < 0:
print('Left Button Pressed')
x,y = pag.position()
print(x,y)
i=0
#pag.moveTo(x, y, duration=1)
pag.mouseDown(x=x, y=y, button='left')
pag.mouseUp(x=x, y=y, button='left')
pag.mouseDown(x=x, y=y, button='left')
pag.mouseUp(x=x, y=y, button='left')
pag.mouseDown(x=x, y=y, button='left')
pag.mouseUp(x=x, y=y, button='left')
pag.mouseDown(x=x, y=y, button='left')
pag.mouseUp(x=x, y=y, button='left')
pag.mouseDown(x=x, y=y, button='left')
pag.mouseUp(x=x, y=y, button='left')
pag.mouseDown(x=x, y=y, button='left')
pag.mouseUp(x=x, y=y, button='left')
else:
print('Left Button Released')
if b != state_right: # Button state changed
state_right = b
print(b)
if b < 0:
print('Right Button Pressed')
else:
print('Right Button Released')
time.sleep(0.001)

浙公网安备 33010602011771号