LoginSignup
1
0

More than 5 years have passed since last update.

Reminders.appで選択中のリマインダーをAppleScriptから取得する苦肉の策

Last updated at Posted at 2016-10-05
  • Reminders.appのAppleScript辞書には選択中のリマインダーを取得するコマンドがない
    • AppleScriptに対応したアプリケーションではFinderのようにselectionなどで取得できるものが多い
  • GUI Scriptingを用いて選択中のリマインダーを無理矢理に取得する
    • GUI Scriptingを使っているので誤動作する可能性が少し高い
    • リマインダーの優先順位を変更するため、選択中のリマインダーをきちんと取得できなかったり元の優先順位が狂ってしまうこともある
    • (2016-10-06 追記) Reminders.appでの見た目と取得したリストの順番が異なる
selectedReminders.scpt
my selectedReminders()
--> {reminder id "x-apple-reminder://BC1CD75A-071E-4093-9DF8-39F293B79BA7"}

on selectedReminders()
    set now to current date
    activate application "Reminders"
    tell application "System Events"
        set frontmost of process "Reminders" to true
        keystroke "1" using {command down}
        keystroke "z" using {command down}
    end tell
    tell application "Reminders"
        set reminderList to reminders whose modification date  now
    end tell
    if reminderList = {} then
        tell application "System Events"
            keystroke "z" using {command down, shift down}
        end tell
    end if
    return reminderList
end selectedReminders

更新履歴

  • 2016-08-30: GUI Scriptingを用いて優先順位を操作する方法で作成
  • 2016-09-01: 選択中のリマインダー以外を取得してしまう不具合を修正
  • 2016-09-01: Reminders.appで1つもリマインダーを選択していない場合に対応
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0