mac上依次顺序安装:
pip3 install pyobjc-framework-Quartz
pip3 install pyobjc-core
pip3 install pyobjc
pip3 install pyautogui
下面这段代码会自动打开mac上的记事本,然后键入对应文本

import time,pyautogui
pyautogui.click(523,735)
try:
    while True:
        time.sleep(2)
        pyautogui.typewrite('HI,DuoDuo,How are you today.\n',0.25)
except KeyboardInterrupt:
        print('\nDone.')