V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
Hear8820
V2EX  ›  问与答

别人分享的一个 OmniFocus 2 的 AppleScript,现在升级了 macOS Mojave 版本 10.14 后,无法在 OmniFocus 中正常使用了。

  •  
  •   Hear8820 · 2018-09-28 21:56:13 +08:00 · 1227 次点击
    这是一个创建于 2252 天前的主题,其中的信息可能已经有所发展或是发生改变。
    求脚本大佬帮助修复一下。

    附上代码
    property pReviewProject : "艾宾浩斯" -- name of project which will receive tasks
    property pReviewIntervals : {3, 8, 15, 30, 60} -- number of days before each repeat, augment as desired
    property pReviewDaysUntilDue : 1 -- allow two days after start date for completion
    property pAutoSave : false -- set this to false for faster performance but slightly more risk


    on GetDefaultDueTime()
    tell application id "OFOC" to tell front document to set timeStr to value of setting id "DefaultDueTime"
    set {otid, text item delimiters} to {text item delimiters, ":"}
    set {dueHour, dueMin, text item delimiters} to every text item in timeStr & otid
    return (((dueHour * 60) + dueMin) * 60)
    end GetDefaultDueTime

    on ProcessAction(selAction, dstProject, dateToday, dueTimeOffset)
    local startDate, dueDate, i
    tell application id "OFOC"
    repeat with i from 1 to (length of pReviewIntervals)
    set newAction to duplicate selAction to end of tasks of dstProject
    set startDate to dateToday + (item i of pReviewIntervals) * days
    set dueDate to startDate + pReviewDaysUntilDue * days + dueTimeOffset
    tell newAction to set {defer date, due date, completed} to {startDate, dueDate, false} -- if user already completed original, we need to make duplicate active
    end repeat
    end tell
    end ProcessAction

    on run {}
    set dateToday to (current date) - (time of (current date))
    set dueTime to my GetDefaultDueTime()
    tell application id "OFOC"
    tell front document
    tell content of first document window
    set lstSelected to value of (selected trees where class of its value is task)
    if ((count of lstSelected) = 0) then
    display alert "No suitable tasks in selection"
    return
    end if
    end tell
    try
    set dstProject to first flattened project whose name is pReviewProject
    on error
    display alert "Could not find destination project \"" & ¬
    pReviewProject & "\""
    return
    end try
    set oldWillAutosave to will autosave
    set will autosave to pAutoSave
    try -- catch any errors and restore autosave setting
    repeat with thisOne in lstSelected
    my ProcessAction(thisOne, dstProject, dateToday, dueTime)
    end repeat
    end try
    set will autosave to oldWillAutosave
    end tell
    end tell
    end run
    2 条回复    2018-10-02 19:41:35 +08:00
    Lax
        1
    Lax  
       2018-09-29 00:07:21 +08:00
    懒得细看了,大概讲讲是做什么的吧
    Hear8820
        2
    Hear8820  
    OP
       2018-10-02 19:41:35 +08:00 via iPhone
    @Lax 就是自动化脚本吧,在 OmniFocus 点一下这个脚本,任务就会按照脚本分成重复的多个任务(截止时间会自动变成脚本设置的时间。

    现在的问题是,我点击这个脚本后,OmniFocus 只能生成脚本中的第一个时间,后面的无法生成的(就是个艾宾浩斯的时间)。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2882 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 15:10 · PVG 23:10 · LAX 07:10 · JFK 10:10
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.