python - 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
解决方案
首先使用 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次)
推荐阅读
- r - 我想在 Server.r 的 UI.r 中使用选定的变量
- python - 确定多行尝试中哪个语句失败
- python - Matplotlib savefig 函数在 Spyder 中不起作用
- swift - 扩展是否每次都返回新实例
- aspnetboilerplate - ABP .net core ,Vue模板请求signarl erver错误
- html - 在 React 组件中,执行
- android - 如何将 Google Play 服务添加到我的虚拟设备?
- android - 当前上下文中不存在名称“AccountPicker”-Xamarin.Android
- git - 远程分支和本地分支之间的差异
- javascript - 正确改写打字稿签名,返回自定义类型而不是方法所需的严格签名