Jump to content

dfay

Member
  • Posts

    1,054
  • Joined

  • Last visited

  • Days Won

    61

Posts posted by dfay

  1. # Mail Interface Management

     

    A collection of scripts for working with Apple Mail.  So far there are four:

     

    **mv** - toggle Mail between the new (as of 10.7) view and the "Classic" (10.6 earlier) view

     

    **mc** - set the interval to check for new mail.  Defaults to automatic.  Specify a time in minutes or "man" for manual.

     

    **check** - check for new mail

     

    **mf** - open the "Flagged" mailbox.  To use “mf”, you need to first add the Flagged mailbox to the Favorites Bar (the list of mailboxes right below the menu).  In my case the Flagged mailbox is the 5th from the left - change the keystroke in the linked “Run Script” object depending on where you have the Flagged mailbox.  This is not an optimal solution b/c if you forget and add another mailbox to the left of Flagged, you'll need to edit the script, but Applescript does not expose the Flagged mailbox directly.

     

    Hosted on Packal:

     


  2. i was just looking into doing this the other day.  Unfortunately Applescript doesn't expose the Flagged mailbox or smart mailboxes.

     

    You can do it with UI scripting if you add the Flagged mailbox to the Favorites Bar (the list of mailboxes right below the menu).  In my case the Flagged mailbox is the 5th from the left, so this works - change the keystroke depending on where you have the Flagged mailbox.  This is not an optimal solution b/c if you forget and add another mailbox to the left of Flagged, you'll need to edit the script.  Also, you need to use a "Run Script" workflow object, set to usr/bin/osascript, not "Run NSAppleScript" (no idea why, but it works in one and not in the other).

     

    activate application "Mail"

     

    tell application "System Events" to tell process "Mail" to keystroke "5" using command down

  3. formatting here is a little weird but this code should work.  Regex is overkill for this task, I think:


     


     


    property lower_alphabet : "abcdefghijklmnopqrstuvwxyz"


    property upper_alphabet : "ABCDEFGHIJKLMNOPQRSTUVWXYZ"


     


    set c to the first character of q


     


    if c is in lower_alphabet or c is in upper_alphabet then


    set theText to "https://my.jira.fqdn/browse/" & q


    else


    set theText to "https://my.jira.fqdn/browse/FOOBAR-" & q


    end if


  4. I swear someone posted the same question in the last month or so and there was a long discussion about it, but I can't find it offhand.  Here is a related discussion:

     

    http://www.alfredforum.com/topic/3830-launch-app-at-specific-time/?hl=schedule#entry22584

     

    Basically there are several utilities that are better suited than Alfred for managing scheduled tasks.  The actual code you'd use will depend on whether you are downloading via browser / Software Update / iTunes etc.

  5. I don't have the RescueTime app but this should be easy in Applescript.  If you look in AppleScript Editor and Open Dictionary... is there an item listed for RescueTime?  If they are good Mac developers, there should be....hopefully then you write an AppleScript to call the GetFocused command.  If not, you would need to kludge through with Applescript GUI scripting and System Events to simulate clicking on the menu -- see e.g. http://macscripter.net/viewtopic.php?id=15198

  6. I thought this might be possible with UI scripting via Applescript but it doesn't look like it is.

     

    I'd try Slate (ref. here: http://apple.stackexchange.com/questions/66560/using-applescript-how-to-move-a-window-to-my-second-display

     

    or maybe Wraparound http://www.macupdate.com/app/mac/19599/wraparound

     

    Unless they are scriptable (I haven't used either) there probably isn't a way to put them into an Alfred workflow, and it doesn't look like either lets you move the mouse directly, but they might solve the problem in other ways.

  7. This is off-topic but are you finding FoldingText ready for prime time?  I have pretty much dropped HogBay software after some incomprehensible design decisions in WriteRoom 2-> 3 (a shame b/c WriteRoom kind of defined the distraction-free writing market niche, then lost it to better competitors....) and the end of development of TaskPaper on iOS (but I love the format -- just using Editorial)....all except TaskPaper on the Mac.  My impression was that a lot of development time was being spent on FoldingText to the neglect of other projects, but FT itself was getting hammered by App Store reviewers so I left it alone.  Would love to hear what you think of it.

  8. Nice.  

     

    I've made a couple modifications you might consider:

     

    I added one line to the DATE_MAPPINGS array in date_format_mappings.py - very clear code that was easy to customize:

     

       
     'yyyy-mm-dd':{'name': 'long inverted US date (-)','date-format':'%Y-%m-%d','regex':'\d{4}-\d{2}-\d{2}'},
    
     
    I added an additional Applescript output from the dcalc script filter with a shift modifier to open Fantastical to the calculated date, with the following very simple script:
     
    on alfred_script(q)
      	tell application "Fantastical"
    		parse sentence (q)
    	end tell
    end alfred_script
    

    This makes for a nice quick way to quickly calculate a date and immediately start adding an event or checking what's on my calendar for that date.

     

     

  9. A simple RPN calculator that works like the built-in calculator.  Requires spaces as delimiters between elements in the expression.  Built using deanishe's Alfred python library.

     

    e.g.

     

    19 2.14 + 4.5 2 4.3 / - *

     

    produces an Alfred result:

     

    85.2974418605

    Action this item to copy this number to the clipboard

     

    There is a single keyword:

     

    rpn

     

    Download link: 

     

    https://www.dropbox.com/s/9ay1z2mubifcun6/RPN Calculator.alfredworkflow?dl=0

     

    2018-07-10: updated with working link

    2020-07-26 updated with latest version of deanishe's Alfred python library.

  10. If you have a local copy of the spreadsheet & it's formatted as a CSV, this can be done with a single line bash script (this is why I put this kind of stuff in Dropbox....).  If you need to call an Evernote or Google Docs API &/or use a proprietary spreadsheet format it gets more complicated b/c you need to authenticate etc.

     

    Take a look at doing: http://www.alfredforum.com/topic/974-doingtxt-a-time-tracking-workflow/

  11. There are two tasks here: 1) is scheduling, 2) is telling iTunes to download a particular movie.

     

    1) is easy to accomplish with launchd or a front end for it like Lingon, which lets you schedule scripts to run at particular times.

     

    2) isn't possible with iTunes existing Applescript dictionary.  It *might* be possible using UI scripting but that would involve a whole lot of simulating mouse clicks and menu selections that would probably need to be customized for each movie or else you might end up buying & downloading stuff you don't want.

  12. I wrote this: http://www.alfredforum.com/topic/1782-save-current-keynote-document-as-pdf/ for Keynote.  The issues are that print dialogs vary from app to app and are generally not visible in Applescript, requiring a whole lot of UI scripting (i.e. simulating the clicks and selections that the user would do with a mouse).  Keynote 6 introduced new dialogs that broke my script, another unfortunate by-product of needing to rely on UI scripting to do this.

     

    I doubt that it would be possible to do this in a generic form, but it is possible for a particular app if you have a lot of patience and time to figure out the UI scripting.

  13. Edited 2014-06-07 to correct issues highlighted by deanishe below

     

    If you are willing to add a separator to separate the stuff at the top from each note, you can use this python script.  In the "Run Script" element of the workflow, language should be set to python and Double Quotes should be escaped. (edited 2014-06-06 to remove extraneous line from testing).

     

    The script will write to an existing file, or, if the specified file doesn't exist, it will create a new file, based on a predefined template.  The template is stored in two parts, a heading (theTemplate - see below), which can be edited in the target notes file without breaking the script, and a separator (theSeparator - see below), which should not be changed in the target notes file. 

     

    To customize the script, there are four variables you can modify:

     

    notesFile - the filename for your notes

     

    theNote - as written, the script inserts the date and time followed by two blank lines ('\n\n') and the text from the command ("{query}").  You can delete the whole date section ("n.strftime('%Y/%m/%d %H:%M:%S')+") or change the formatting - I used the guidelines at http://www.cyberciti.biz/faq/howto-get-current-date-time-in-python/ ).

     

    theSeparator - I used '## Notes ##' b/c this will look nice in Markdown but is also unlikely to appear anywhere else.  You can hypothetically use any text.  You should not change this in your target notes file without also changing it in the script, or the script will stop working.

     

    theTemplate - I based this on the request earlier in these forums - again, this can be changed to whatever you want.

    #!/usr/bin/python
    
    from datetime import datetime
    import os
    
    notesFile = '/Users/your home/Desktop/notes.txt' # your path and filename go here
    n = datetime.now()
    theNote = n.strftime('%Y/%m/%d %H:%M:%S')+'\n\n'+"{query}"
    # to reformat the date see http://www.cyberciti.biz/faq/howto-get-current-date-time-in-python/
    
    theSeparator = '## Notes ##'
    theTemplate = '# NoteTitle\n= Notebook\n@ tag1'
    
    if not os.path.exists(notesFile):
       with open(notesFile, 'w') as file:
          file.write('{}\n\n{}\n\n{}'.format(theTemplate, theSeparator, theNote))
    else:
       with open(notesFile, 'r') as file:
          notes = file.read()
       with open(notesFile, 'w') as file:
          sections = notes.split(theSeparator,1)
          notes = sections[0]+theSeparator+'\n\n'+theNote+'\n'+sections[1]
          file.write(notes)
    
    
  14. Stephen - do you have a github repo for this?  I have a bunch of related workflows, most of which depend on having that Applescript URL handler you wrote installed (and then having the top 3 notes generated on the current PDF so that the page # conversion will work).  I have been lazy to post them here and wasn't sure about it since they are largely adaptations of your underlying hard work.  Here is what they do - let me know & I can get them to you somehow - if you want to incorporate them it seems it might make more sense to consolidate them in a single workflow.

     

    Generate Top 3 Notes in Skim

    Export all Skim notes to Clipboard with MD links

    Copy Markdown Reference Link for current Skim page

    Copy Markdown Inline Link for current Skim page

    Copy current Skim page # to clipboard

    Go to Page in Skim

     

    --Derick

  15. Updated to filter based on query.  I am leaving assigned and unassigned in the output -- this can be easily changed by editing list_hotkeys.py in the workflow directory & changing the line:

     

    results = start+end
     
    to
     
    # defined hotkeys only
    results = start
     
    or
     
    # undefined hotkeys only
    results = end
×
×
  • Create New...