I decided to try to do a code to automatically convert a ducky code into a python code (at least at a simple level), and the first thing I wanted to do was changing the STRING
in the ducky code to python using pynput. The equivalent of STRING
is keyboard.type()
, defining keyboard as pynput.keyboard.Controller()
.
So, for example, the code should turn this:
STRING hello
STRING how are you?
Into this:
keyboard.type("hello")
keyboard.type("how are you?")
What I've tried was this:
ducky=input("Introduce your ducky code... \n")
py=ducky.replace("STRING", '''keyboard.type("''')
That code works, but it doesn't put the quotation marks and the parenthesis at the end of each line, and I don't know how to do that. Can anyone help me?
Also, I'm a beginner, and I tried to use .replace
for this because I know how it works, but if there is something better to use in this case, please, tell me.
Thanks.