Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python Keyboard Module doesn't work without root

Currently, I have written a code for a voice assistant which can write with users voice. I use python keyboard module from pip. But when I execute the code it shows me that it cannot write without root.

the code is given below,

elif (t.find("type") != -1):

    le = t.find("type") + len("type") + 1
    t = t[le:]
    try:
        print("Typing> ", t)
        keyboard.write('' + t+". ")
    except:
        print("Can't Type")
like image 399
Santo Shakil Avatar asked Nov 06 '22 18:11

Santo Shakil


1 Answers

No, you cannot read or write using the keyboard module unless you are root. I have had the same problem, sadly. But Pynput worked perfectly using the pynput.keyboard.Listener class.

like image 178
cs1349459 Avatar answered Nov 15 '22 10:11

cs1349459