Search code examples
pythonpython-multithreadingpyautogui

Exception in thread thread-2 , TypeError: clickc() argument after * must be an iterable, not bool


I am trying to make an auto clicker controlled with keyboard . And I get

Exception in thread thread-2

indeed I get

TypeError: clickc() argument after * must be an iterable, not bool

import keyboard, pyautogui as pag 
import time
import threading 

number = 9999999999999999999999999999999999999999999999999999999999999999999999999999999

fk = False

def clickc(fk):
    if fk == True:
        pag.click(button="left", clicks=5, interval=1)
    else: 
        return None


def keycontrol(x, shutdown):
    try: 
        if keyboard.is_pressed(x):
            return True
        if keyboard.is_pressed(shutdown):
            return False
    except: 
        pass

p1 = threading.Thread(target=keycontrol, args=("f","v"))

p0 = threading.Thread(target=clickc, args=fk)

fk = p1.start()
p0.start()

Here is the full error :

Exception in thread Thread-2:
Traceback (most recent call last):
  File "C:\Users\muham\AppData\Local\Programs\Python\Python38-32\lib\threading.py", line 932, in _bootstrap_inner
    self.run()
  File "C:\Users\muham\AppData\Local\Programs\Python\Python38-32\lib\threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
TypeError: clickc() argument after * must be an iterable, not bool
[Finished in 0.4s]

Solution

  • Your 'p0' args should be an iterable (a tuple, list, etc) like the 'p1':

    p0 = threading.Thread(target=clickc, args=(fk,))