如何使用rb-appscript或AppleScript在TextMate中创建新文档?
下面是我的rb-appscript:
te = app("TextMate")
te.launch
doc = te.make(:new => :document)但它不起作用。
下面是我得到的错误消息:
OSERROR: -10000
MESSAGE: Apple event handler failed.
COMMAND: app("/Applications/TextMate.app").make({:new=>:document})如果有人给我一个AppleScript代码,我可以把它转换成rb-appscript。
发布于 2010-08-23 02:22:21
从技术上讲,它应该是这样的:
tell application "TextMate"
set theResult to make new document
end tell但是我在脚本调试器中得到了同样的错误。手动创建新文档并通过脚本获取文档效果良好。我要说你在TextMate的Applescript实现中发现了一个bug。您可以在此处使用图形用户界面脚本( (shamelessly copied from the Mac OS Automation site):
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_menuhttps://stackoverflow.com/questions/3542363
复制相似问题