Jump to content


  • Content Count

  • Joined

  • Last visited

Posts posted by squandre

  1. Hi CJK,


    Thanks for taking the time to review and optimize the script, appreciate it! ?

    The delay still persists though. It's weird because I have other (albeit slightly smaller) scripts that I run with Alfred and they run without delay.

    When I run your script with the Script Editor, it runs instantaneously but as soon as I run it with Alfred (or turn it into an application) there's a delay of (I think exactly) 5 seconds each time.


    Some screenshots:





    Schermafbeelding 2018-10-31 om 09.17.07.png

    Schermafbeelding 2018-10-31 om 09.17.27.png

  2. Hi!

    I've found a great script online (credits are in comment in the script) that allows me to set a reminder for an email. When I execute it from the Scripteditor or use it as a service in Mail, it works instantaneously. But when I add it to Alfred as an applescript, or run it as an application, it takes 5 seconds to execute...

    Any ideas how I might get the same performance from Alfred?

    PS: I'm not a programmer but I have some limited coding experience.


    # Title: Create reminder from selected Mail
    # By Michael Kummer and partly based on various code snippets I found online
    # michaelkummer.com
    # You can use the source as you wish but do so at your own risk
    # Have a backup of your data to avoid accidental loss
    # Last update: March 18th, 2014
    # Version: 0.1
    # Tested on OS X 10.9.2 Mavericks
    # Description
    # When installed as a Service, this AppleScript script can be used to automatically create a reminder (in pre-defined Reminder lists)
    # from a selected email and flag the email.
    # If you run the script against an email that matches an existing reminder it can mark the reminder as completed and clear the flag in Mail
    # Contributors and sources
    # Rick0713 at https://discussions.apple.com/thread/3435695?start=30&tstart=0
    # http://www.macosxautomation.com/applescript/sbrt/sbrt-06.html
    # Set this according to your email account names and Reminder's lists
    set WorkAccountName to "Exchange"
    set WorkRemindersList to "Work"
    set PersonalAccountName to "iCloud"
    set PersonalRemindersList to "Personal"
    # On my machine 5 is the Purple flag, which is the color I would like to use for mails flagged as Reminder
    set FlagIndex to 5
    tell application "Mail"
    set theSelection to selection
    # do nothing if no email is selected in Mail
    set theMessage to item 1 of theSelection
    on error
    end try
    set theSubject to theMessage's subject
    # Make sure reminder doesn't already exist so we don't create duplicates
    tell application "Reminders"
    set theNeedlesName to name of reminders whose name is theSubject and completed is false
    if theNeedlesName is not {} then
    # make sure dialog is in focus when called as a service
    # without the below, Mail would be the active application
    tell me
    end tell
    set theButton to button returned of (display dialog "The selected email matches an existing reminder: " & theNeedlesName & ". Would you like to mark the reminder as complete and clear any remaining flags of this message?" with title "Create Reminder from E-Mail" buttons {"Mark complete", "Cancel"} default button 1)
    if theButton is "Mark complete" then
    tell application "Mail"
    # unflag email/message
    set flag index of theMessage to -1
    end tell
    # find correct reminder based on subject and mark as complete
    set theNeedle to last reminder whose name is theSubject and completed is false
    set completed of theNeedle to true
    else if the_button is "Cancel" then
    end if
    end if
    end tell
    # present user with a list of follow-up times (in minutes)
    (choose from list {"Tomorrow", "2 Days", "End of Week", "1 Week", "1 Month", "3 Months"} default items "End of Week" OK button name "Create" with prompt "Set follow-up time" with title "Create Reminder from E-Mail")
    set reminderDate to result as rich text
    # Exit if user clicks Cancel
    if reminderDate is "false" then return
    if reminderDate = "Tomorrow" then
    # add 1 day and set time to 9h into the day = 9am
    set remindMeDate to (current date) + 1 * days
    set time of remindMeDate to 60 * 60 * 9
    else if reminderDate = "2 Days" then
    set remindMeDate to (current date) + 2880 * minutes
    else if reminderDate = "End of Week" then
    # end of week means Thursday in terms of reminders
    # get the current day of the week
    set curWeekDay to weekday of (current date) as string
    if curWeekDay = "Monday" then
    set remindMeDate to (current date) + 3 * days
    else if curWeekDay = "Tuesday" then
    set remindMeDate to (current date) + 2 * days
    else if curWeekDay = "Wednesday" then
    set remindMeDate to (current date) + 1 * days
    # if it's Thursday, I'll set the reminder for Friday
    else if curWeekDay = "Thursday" then
    set remindMeDate to (current date) + 1 * days
    # if it's Friday I'll set the reminder for Thursday next week
    else if curWeekDay = "Friday" then
    set remindMeDate to (current date) + 6 * days
    end if
    set time of remindMeDate to 60 * 60 * 9
    else if reminderDate = "1 Week" then
    set remindMeDate to (current date) + 10080 * minutes
    else if reminderDate = "1 Month" then
    set remindMeDate to (current date) + 43200 * minutes
    else if reminderDate = "3 Months" then
    set remindMeDate to (current date) + 129600 * minutes
    end if
    # Flag selected email/message in Mail
    set flag index of theMessage to FlagIndex
    # Get the unique identifier (ID) of selected email/message
    set theOrigMessageId to theMessage's message id
    #we need to encode % with %25 because otherwise the URL will be screwed up in Reminders and you won't be able to just click on it to open the linked message in Mail
    set theUrl to {"message:%3C" & my replaceText(theOrigMessageId, "%", "%25") & "%3E"}
    # determine correct Reminder's list based on account the email/message is in
    if name of account of mailbox of theMessage is WorkAccountName then
    set RemindersList to WorkRemindersList
    else if name of account of mailbox of theMessage is PersonalAccountName then
    set RemindersList to PersonalRemindersList
    #default list name in Reminders
    set RemindersList to "Reminders"
    end if
    end tell
    tell application "Reminders"
    tell list RemindersList
    # create new reminder with proper due date, subject name and the URL linking to the email in Mail
    make new reminder with properties {name:theSubject, remind me date:remindMeDate, body:theUrl}
    end tell
    end tell
    # string replace function
    # used to replace % with %25
    on replaceText(subject, find, replace)
    set prevTIDs to text item delimiters of AppleScript
    set text item delimiters of AppleScript to find
    set subject to text items of subject
    set text item delimiters of AppleScript to replace
    set subject to "" & subject
    set text item delimiters of AppleScript to prevTIDs
    return subject
    end replaceText


  3. I made a new version that checks whether Do Not Disturb is currently enabled, and lets you know which way you'll be toggling it. It then notifies you.


    No idea why it doesn't work with Bartender. If anyone has any suggestions for that problem or for improvements, by all means go ahead.




    I have tried every version of this and it doesn't seem to work. Running El Capitan 10.11.6 in Dutch.

  4. I love this workflow man, thanks!



    I only have one "bug" to report:


    Whenever I type "SMS [contact name]", it goes to the messages app and it opens the dialog window for that person, ready to type and send a text message. As it should, no problem there.



    But then I noticed:


    When the messages app is open and the contact person's dialog window is already in focus, the same command via Alfred: instead of using the text number, it changes to iMessage mode and I can't send a text as it wants to use imessage instead. (contact doesn't have an iphone)


    Maybe you could implement a check that, if the person already is in focus, stop looking or something. I dunno, I'm not a programmer :)



    I can make a video of the problem if you want, it's nothing major but it upsets the goal of the workflow though.

  5. Hi!



    I just bought the Powerpack and I already have some great workflows installed.


    The only thing I'm wondering is: Is there a way to sort of default a workflow into Alfred? So that a keyword isn't necessairy?


    I have this Google Chrome Bookmarks search installed (http://www.alfredforum.com/topic/2362-search-google-chromechromium-bookmarks/)

    And I'd love it, if I could just turn on Alfred and immediately start going through my bookmarks. Now I have to first type "chrome", then space, and then I can search. But this feels a bit unatural to me. I just want to start up Alfred and have my Chrome bookmarks available!






    A newcomer

  • Create New...