2017-03-21 3 views
0

미리 알림 응용 프로그램에서 미리 알림 데이터를 내보내려고합니다. 아래의 스크립트는 그렇게 할 것입니다. 그러나 매우 오랜 시간이 걸립니다 (첫 번째 반복에는 100 분이 걸리고 두 번째 반복은 여전히 ​​실행 중입니다).Applescript Profiling/Efficiency : 응용 프로그램에서 개체 및 개체 세부 정보 목록 내보내기

나는 (그 중 1,000 주변이 경우) AppleEvents를 전송하는 성능을 죽이는 것입니다,하지만 수정 (내가 script 내부 end scriptrun script을 스크립트를 캡슐화에 대해 읽고하지만이 할 것 같지 않았다 스파 스 것을 읽고 아무것도).

내가 시도하지 않은 유망하지만 번거로운 방법은 열 열을 모두 따로 따로 가지고 유닉스 paste을 함께 모으는 것입니다.

진짜 문제는 물론 내 테이블의 모든 셀을 하나씩 찾는 것입니다. rs에있는 모든 객체 (미리 알림)를 참조로 나열하는 것이 아니라 값별로 자세히 잡아낼 수 있습니까? 그렇다면 나는 그것을 어떻게 해석 할 수 있는가.

#!/usr/bin/osascript 

set output to "Title,Notes,Completed,Completion Date,List,Creation Date,Due Date,Modification Date,Remind Me Date,Priority\n" 

tell application "Reminders" 
    set rs to reminders in application "Reminders" 
    repeat with r in rs 
     set output to output & "\"" & name of r & "\",\"" & body of r & "\",\"" & completed of r & "\",\"" & completion date of r & "\",\"" & name of container of r & "\",\"" & creation date of r & "\",\"" & due date of r & "\",\"" & modification date of r & "\",\"" & remind me date of r & "\",\"" & priority of r & "\"\n" 
    end repeat 
end tell 
return output 

답변

0

나는 약 1 년 늦었지 만 다른 사람이이 솔루션을 유용하게 사용할 수 있습니다. 트릭은 변수 rs에 미리 알림에 대한 참조를 저장하는 것입니다. 그렇게하면 AppleScript는 repeat 루프에서 속성을 검색하기 위해 모든 미리 알림을 한 번만 처리하면됩니다. 또한

use application "Reminders" 

    set text item delimiters of AppleScript to "|" 

    set output to {{"Title", "Notes", "Completed", "Completion Date", ¬ 
     "List", "Creation Date", "Due Date", "Modification Date", ¬ 
     "Remind Me Date", "Priority"} as text} 


    set rs to a reference to reminders 

    repeat with r in (a reference to reminders) 
     get {name, body, completed, completion date, ¬ 
      name of container, creation date, due date, ¬ 
      modification date, remind me date, priority} ¬ 
      of r 

     set end of output to the result as text 
    end repeat 

    set text item delimiters of AppleScript to "\n" 

    return output as text 

변수 rs을 정의한 후, 하나는 다음과 같이 한 번에 모든 알림의 모든 속성을 얻을 수 :

set everything to the properties of rs 

그리고 대신에이 목록을 통해 루프 :

repeat with r in everything 
     (* same as above *) 
      . 
      . 
      .