I'm a beginner programmer and have been writing a few very simple scripts in python to automate opening up a few apps and chrome tabs for a workflow session. Apologies if my question is very simple but have been looking everywhere for an answer, trying everything and have not got to the point of just randomly trying things and not sure where to go next... I've basically hit a complete block.
The bit that I can't get to work is calling an apple script that I found online to maximise a chrome window from within python. The code I have works exactly as I want it to if I paste and run it directly in the terminal (I'm on Mac OS X), but for some reason, when I try to call the same piece of code from within python using os.system or subprocess.call (which I believe is the more modern version), it doesn't work.
The code that works in the terminal is as follows:
osascript -e "tell application \"google chrome\"" -e "activate" -e "tell application \"System Events\"" -e "keystroke \"f\" using {control down, command down}" -e "end tell" -e "end tell"
However, when called as follows in python, it doesn't work - and gives the error below in the terminal.
import subprocess
args = ' -e "tell application \"google chrome\"" -e "activate" -e "tell application \"System Events\"" -e "keystroke \"f\" using {control down, command down}" -e "end tell" -e "end tell"'
subprocess.call("osascript" + args, shell=True)
syntax error: Expected end of line but found end of script. (-2741)
Any help really appreciated!
Thanks