I'm new to Python and trying to automate a process on my computer, but I'm having trouble. I've already written my Python script with what I want to print, but I'd like to have my own code to press enter after that. I tried "keyboard.press(Key.enter)," but my code does not run on the terminal.
Here is the code:
from pynput.keyboard import Key, Controller
keyboard = Controller()
print(''"export SPOTIPY_CLIENT_ID='123'"'')
print(''"export SPOTIPY_CLIENT_SECRET='123'"'')
keyboard.press(Key.enter)
keyboard.release(Key.enter)
#suppose to press return
print('savify "https://open.spotify.com/playlist/37i9dQZEVXbMDoHDwVN2tF?si=eac8b42e32934a6c" -q best -f mp3 -o "/Users/" -g "%artist%/%album%"')
keyboard.press(Key.enter)
keyboard.release(Key.enter)
#suppose to press return
I expected it to run my program but it just goes to the other line.
I understood your problem, don't print those commands, instead go to the CLI tab and type them.
import pyautogui as gui
import time
time.sleep(5) # Time you should take to switch to the command line tab on foreground
gui.write("export SPOTIPY_CLIENT_ID='123'")
gui.write("export SPOTIPY_CLIENT_SECRET='123'")
gui.press('enter')
#suppose to press return
gui.write('savify "https://open.spotify.com/playlist/37i9dQZEVXbMDoHDwVN2tF?si=eac8b42e32934a6c" -q best -f mp3 -o "/Users/" -g "%artist%/%album%"')
gui.press('enter')
#suppose to press return