Python连击器

Python连击器

代码:

from pymouse import PyMouse
import time
from pynput import keyboard
import threading
flag = False
def on_press(key):
    """
    键盘监听事件!!!
    :param key:
    :return:
    """
    #print(key)
    global flag
    if key == keyboard.Key.esc:
        flag=True
        print("stop monitor!")
        return False  #返回False,键盘监听结束!
 
 
def mouseclick():
    m = PyMouse()
    a = m.position()    #获取当前坐标的位置
     
    while True:
 
        m.click(a[0], a[1])  #移动并且在(x,y)位置左击
        #print('dianjile')
        time.sleep(0.005)
        if flag:
            print("测试结束!")
            break
        #m.click(300, 300, 2) #(300,300)位置右击
 
if __name__ == '__main__':
    print('请将鼠标移动到点击位置,10秒后自动点击')
    time.sleep(10)
    th=threading.Thread(target=mouseclick)
    th.start()
    with keyboard.Listener(on_press=on_press) as listener:
        listener.join()

你可能感兴趣的:(Python,python,wifi)