2011-02-18 8 views
3

이것은 응용 프로그램 특정 문제입니다. 내 안에 내용에 따라 Terminal.app에서 탭을 찾아 선택하려고합니다. 내가하는 일이 여기에 있습니다 :applescript 및 모범 사례를 사용하여 콘텐츠에 따라 터미널의 특정 탭을 선택하십시오.

tell application "Terminal" 
    set foundTabs to (every tab of every window) whose contents contains "selectme" 
    repeat with possibleTab in foundTabs 
     try 
      set selected of possibleTab to true 
     end try 
    end repeat 
end tell 

이것은 예상대로 작동하지 않으며 매우 이상하지 않습니다. 누군가가 훨씬 적은 코드로 이것을 수행 할 수있는 방법을 제안 할 수 있는지 궁금합니다 (예를 들어 루핑이 실제로 필요하지는 않지만 applescript는 애매한 언어 임).

답변

2

것입니다

덕분에, 다음 AppleScript를 당신이 원하는 것을 할 것입니다,하지만 "selectme"문자열이 매우 독특한하지 않는 한, 당신은 많은 탭에서 찾을 수 있습니다. 하지만 어쨌든, 여기에 당신이 간다 :

tell application "Terminal" 
set allWindows to number of windows 

repeat with i from 1 to allWindows 
    set allTabs to number of tabs of window i 
    repeat with j from 1 to allTabs 
     if contents of tab j of window i contains "selectme" then 
      set frontmost of window i to true 
      set selected of tab j of window i to true 
     end if 
    end repeat 
end repeat 
end tell 
+0

마다 그것을 사용하는 어떤 방법이 있습니까? 너의 작품. 나는 단지 'every'키워드를 활용하기를 원했습니다. 예를 들면 다음과 같습니다 :'select in "(모든 윈도우의 모든 탭)에 내용이"selectme ​​" – umop