
我已經可以使用終端關閉整個應用程序,但是當涉及到關閉文字編輯中的特定視窗時,我無法做到這一點。為什麼我可以使用終端機開啟特定文件,但現在也可以關閉它們?
答案1
我不知道如何做到這一點,但這裡有一個使用 python 程式中的 applescript 的解決方法:
os.system(f'''/usr/bin/osascript -e 'tell app "TextEdit" to close (every window whose name is "allen_grammar.txt")' ''')