Python Forum

Full Version: Beginner needs help with code
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello, I am a newbie to the world of coding and python at the age of 13, I have a kali machine and I have been messing around with the Lazy Script. I decided I wanted to make it more automated, so i have been messing around and learning about python and i made this script to start automating what i wana do.

#!/root/
       #Imports 
       import time
       from pynput.keyboard import Key, Controller
       import subprocess
       from subprocess import call
       #Defines the key controller as keyboard
       keyboard = Controller()
       #opens the lazy script
       subprocess.call('l')
       time.sleep(1)
       keyboard.press('9')
       time.sleep(1)
       keyboard.release('9')
I am able to open the lazy script program, but to get to the next menu you have to type 9 and press enter. i tried different things like simulating keys but it didn't work. Anyone have any suggestions? I feel like there is a simpler way than simulating keys but i don't know it. Thank you for taking your time to read this thread Dance
You can perhaps try
process = subprocess.Popen(['l'], stdin=supbrocess.PIPE)
process.stdin.write('9\n')
process.wait()