从技术上讲,它应该是这样的:
tell application "TextMate"
set theResult to make new document
end tell
但是我在脚本调试器中遇到了同样的错误。手动创建新文档并通过脚本获取文档可以正常工作。我要说你在 TextMate 的 Applescript 实现中发现了一个错误。你可以在这里走 GUI 脚本路线(无耻地从 Mac OS 自动化站点复制):
return do_menu("TextMate", "File", "New")
--> result: true and a window appeared in TextMate
on do_menu(app_name, menu_name, menu_item)
try
-- bring the target application to the front
tell application app_name
activate
end tell
tell application "System Events"
tell process app_name
tell menu bar 1
tell menu bar item menu_name
tell menu menu_name
click menu item menu_item
end tell
end tell
end tell
end tell
end tell
return true
on error error_message
return false
end try
end do_menu