2010-08-22 5 views
0

rb-appscript 또는 AppleScript를 사용하여 TextMate에서 새 문서를 만드는 방법은 무엇입니까?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}) 

내가 RB-appscript을로 변환 할 수 있습니다 : 여기

은 내가 오류 메시지입니다.

+0

이 두 사람이 관심을 가질만한 생각 http://ticket.macromates.com/show?ticket_id=98A3E754을 – mcgrailm

답변

3

기술적으로, 단지이해야하는데 :

tell application "TextMate" 
    set theResult to make new document 
end tell 

하지만 스크립트 디버거에서 같은 오류가 발생합니다. 수동으로 새 문서를 만들고 스크립트를 통해 문서를 가져 오는 것이 좋습니다. TextMate의 Applescript 구현에서 버그를 발견했다고 말할 것입니다. 당신은) 여기 (shamelessly copied from the Mac OS Automation site을 GUI 스크립팅 길을 갈 수 :

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