Skip to content
Advertisement

I made a simple keylogger program using python but it displays “TypeError: write_file() takes 0 positional arguments but 1 was given”

This is my main program, and I have used pynput library to make this program:

JavaScript

On console, the program keeps track of all the keys being pressed but when the count reaches it’s limit, instead of storing the data in “log.txt” it displays:

JavaScript

As you can see, I was trying to write “Hello World” but as soon as I reach the word R in “Hello World” the program throws the TypeError on me

Advertisement

Answer

Remove one write-command from write_file() to avoid duplicate output to the logfile. I have modified the code slightly, see inline comments.

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement