首页 > 解决方案 > Using python to make an auto clicker

问题描述

I want to make an auto clicker using python. Here is a kind of idea of what I have going. I would like it so when I click it'll click 10 times.

import mouse

def clicker():
    if mouse.if_click('left'):
        mouse.click('left')
        mouse.click('left')
        mouse.click('left')
        mouse.click('left')
        mouse.click('left')
        mouse.click('left')

clicker()

Any ideas???? Thanks

标签: pythonpython-3.xclickmouseevent

解决方案


首先使用 pip 安装 pyautogui

pip install pyautogui

代码:-

import pyautogui, time
time.sleep(2)
x = 0
times = 20 # Change this to the number of times you want it to click

while True:
    if x == times:
        print("Stopped Clicking")
        break

    else:
        pyautogui.leftClick()
        x += 1

这段代码左键点击变量中设置的次数times(这里是20次)


推荐阅读