Skip to content

[已解決][AppleScript] error “System Events got an error: Script Editor is not allowed to send keystrokes.” number 1002

今天在我嘗試使用 AppleScript 撰寫一個腳本(使用 Script Editor),主要是讓系統自動幫忙輸入文字。但在執行時,卻得到以下錯誤訊息:

error "System Events got an error: Script Editor is not allowed to send keystrokes." number 1002

解決方法

這是 Mac OS 的一個安全性防護機制,為了避免沒有授權的指令操作 System Events。要解決這個問題最快的方式,就是給予我使用的軟體 Script Editor 存取權限。

依照以下順序打開頁面:左上角蘋果圖示 > System Preferences… > Security & Privacy > Accessibility

先解鎖再選擇新增
找到 Script Editor

接著應該就能成功執行腳本了。


Reference


Read More

Leave a Reply