Python pyautogui/pynput 点击功能 [英] Python pyautogui/pynput click function

查看:97
本文介绍了Python pyautogui/pynput 点击功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试制作一个简单的自动点击器,但它对我不起作用.我的光标像 f*** 一样缓慢移动.你们知道如何解决这个问题吗?

I tried making a simple autoclicker but it is not working for me.My cursor is moving slowly as f***. You guys have an idea how to fix this?

问题:第 11 行,pyautogui.click(button='left') 没有点击.

Problem: line 11, pyautogui.click(button='left') is not clicking.

from pynput.mouse import Listener, Button, Controller
import pyautogui

# This function will be called when any key of mouse is pressed
def on_click(*args):
    # see what argument is passed.
    print(args)
    if args[-1]:
        # Do something when the mouse key is pressed.
        print('The "{}" mouse key has held down'.format(args[-2].name))
        pyautogui.click(button='left')           # <--- lagging mouse

    elif not args[-1]:
        # Do something when the mouse key is released.
        print('The "{}" mouse key is released'.format(args[-2].name))


# Open Listener for mouse key presses
with Listener(on_click=on_click) as listener:
    # Listen to the mouse key presses
    listener.join()

推荐答案

在我的 Windows 10 计算机上运行来自问题的主题海报代码导致 Python 窗口无法关闭一个小时,我无法使用 Task 关闭它经理.

On my Windows 10 Computer running the topic poster code from question led to Python window that doesn't close for an hour and I can't close it with Task Manager.

所以执行这段代码时要小心.

So be careful with executing this code.

这篇关于Python pyautogui/pynput 点击功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆