TypeError:“按钮”对象不可调用pynput

问题描述

我(和我的朋友)正在自动敲门声,我编写的代码(自己工作)对她不起作用。我收到错误消息:TypeError: 'Button' object is not callable我认为这与Pynput有关

我不知道要尝试什么,(我做的很明显,谷歌)

以下是发生错误代码

def clickerstart():  #this functions activates when you press the "start" button in the autocklicker menu      ¦
#                                                                                                              ¦
    if clickerlmb == 1: #if you sellected to click the LMB then this block of code whill be run                ¦
#                                                                                                              ¦
        for i in range(0,clickertime): #looping for "clickertime" so we get more than 1 second of clicking    ¦
#                                                                                                              ¦
            for i in range(0,cps): #looping for the cps so we get more than 1 click                           ¦
#                                                                                                              ¦
                delay = 1 / cps #working out the delay from the cps value                                      ¦
                mouse.press(Button.left) #pressing the LMB...                                                  ¦
#                                                                                                              ¦
                time.sleep(int(delay)) #sleeping for the before worked out time                                ¦
                mouse.release(Button.left) #...and releasing it                                                ¦
#                                                                                                              ¦
#                                                                                                              ¦
    if clickerrmb == 1: #if you sellected to click the LMB then this block of code whill be run                ¦
#                                                                                                              ¦
        for i in range(0,cps): #looping for the cps so we get more than 1 click                           ¦
#                                                                                                              ¦
                delay = 1 / cps #working out the delay from the cps value                                      ¦
                mouse.press(Button.right) #pressing the RMB...                                                 ¦
#                                                                                                              ¦
                time.sleep(int(delay)) #sleeping for the before worked out time                                ¦
                mouse.release(Button.right) #...and releasing it                                               ¦

解决方法

这是因为您没有使用f分配按钮给任何东西vnbrs.localhost:4001

我想就是这样。您必须定义它。