Jump to content

Stephen_C

Community Hero
  • Posts

    1,347
  • Joined

  • Last visited

  • Days Won

    65

Posts posted by Stephen_C

  1. This is a simple little workflow (which requires Alfred 5) to return the name of the weekday of any given date. The given date must be in the format dd/mm/yyyy (e.g., 28/08/2022) and there is some basic validation of user input (although I've no doubt the poor little thing will break if you kick it hard enough 😀). It relies on AppleScript at its core.

     

     

    Get the weekday of a given date on Github.

     

  2. Just checking, but from this Alfred help page:

     

    Quote

    Alfred 4 and 5 can cohabitate quite happily; You cannot run both apps at the same time, but you can switch between them, and keep both installed if you need to.

     

    I'm assuming you're not trying to run both at the same time but thought it worth just checking. Sorry if that doesn't help.

     

    Edit: What are the exact error messages?

     

    Stephen

  3. I rather hesitate to post this pretty basic workflow here but it demonstrates (albeit with far less sophistication than the workflow under discussion) what you can do with date arithmetic in Alfred—and without any external dependence (in other words, you don't need Python, for example). Do note there's no evaluation of the validity of the input so you need to make sure you're using the date commands correctly (see Date arithmetic on this Alfred help page).

     

    The workflow looks like this:

     

    Workflow.thumb.jpg.d8a8ba5a17e7df45b3e29e35f15c58bb.jpg

     

    The Keyword action simply responds to the date keyword and expects a <space> and an argument (e.g., -1Y -17D)—with the subtext giving examples of the correct fornat for the date arithmetic. The Arg & Vars utility is set up like this:

     

    679703437_Argvars.thumb.jpg.a2cf09f35593bcaa0b9c096db434eb2e.jpg

     

    and the Dialog Conditional like this:

     

    Dialog.thumb.jpg.af5c9e1bd0094bcb2150ff2a3d0a87cf.jpg

     

    After that it's merely a matter of noting that, of course, what you want to send to the clipboard is {var:newDate}. The notification simply confirms the relative date has been copied to the clipboard (rather than just letting the workflow die quietly leaving you wondering if it has actually done anything).

     

    Stephen

  4. Vitor's idea of using the Dialog Conditional action is very much better than my AppleScript so here's what to do if you want to adopt it.

     

    Substitute this (as an example) for my Run Script action:

     

    1474422940_Amendedworkflow.jpg.a619f8383830a897a428617f2c32f9b4.jpg

     

    Here's what my Dialog Conditional action looks like:

     

    Dialog.thumb.jpg.2bc90da620595516468029167ddbb175.jpg

     

    Note that for the <Enter> key in the Description box you must press Option + <Enter>. By having Quit the workflow as the first button it's possible to quit the workflow simply by pressing <Enter>.  In the final Clipboard action make sure you include {query} as the text to be copied to the clipboard.

     

    Stephen

  5. 1 hour ago, vitor said:

    Have you considered the Dialog Conditional?

    Do you know, I never even noticed that in Alfred 5! Thanks so much for pointing it out. As you imply, it's much more versatile than the script I used. I can use that now in several of my workflows: it's really useful.

     

    I thought I'd read carefully all the information on the Alfred help pages about Alfred 5 but I clearly did not do so carefully enough!

     

    Stephen

  6. Vitor:

     

    I much appreciate the long and considered response. I'd already seen the blog post to which you referred and will certainly take a look at the other workflows you mention. By strange coincidence I started looking this morning at JXA and as a result had come across the JXA Cookbook. I have to say that the initial meeting with JXA was not a particularly enlightening experience. 😀 It will clearly require considerably more effort on my part. The native support for JSON is attractive, of course.

     

    I need to study more, so thanks for the pointers. I do still wonder if it might be useful for others (as well as me) to have something like a weekly/monthly workflow analysed in detail. However, I do appreciate that those who could do that also have lives to lead!

     

    Stephen

  7. This workflow is very simple but uses a small piece of AppleScript to display the result in a dialogue box than can be simply dismissed by pressing <Enter>. (I don't always want results copied to the clipboard or displayed in large type so, for me, a small informative dialogue box was the answer.)

     

    The workflow looks like this:

     

    753434781_wordcount.thumb.jpg.da8f31db3fff849d779540f5d7b4a5e0.jpg

     

    The Universal Action is set to operate on text only (of course). The Automation Task is set to count words and the AppleScript looks like this:

     

    AppleScript.thumb.jpg.a48c1899838927406a1a761f137956cc.jpg

     

    All you have to do, when the workflow is set up, is to select some text, press the Universal Action shortcut keys and run Word count.

     

    I do look forward to hearing from others what you are doing with Universal Actions.

     

    Stephen

  8. When you import a workflow the hotkey it uses is stripped (in case it conflicts with a hotkey you are already using).

     

    There are probably two ways you can add the hotkey:

     

    - It will definitely work if you double click on the Hotkey action in the workflow and then add the case keyword.

    - The author of the workflow may have enabled the facility to change the hotkey if you click on Configure Worklow at the top of the workflow window (under the name of the workflow).

     

    Stephen

  9. Sometimes I feel my imagination needs a poke. 😀 I've slowly discovered more and more things that I can do with Alfred and have many workflows—most of which I consider to be pretty basic (e.g., app launchers, search workflows and some which are very slightly more sophisticated and use AppleScript). I've never really got to grips with script filters so today re-wrote two workflows (one to open files from a pre-selected list and one to go to folders from a pre-selected list) simply to understand a little more not only about how script filters actually work but why people might use them. In the course of doing that I downloaded and studied a number of workflows to see what people were doing with them—and, of course, read Alfred's help pages.

     

    I guess I fall somewhere between an absolute basic user of Alfred (someone who maybe does little more than launch apps and searches with it) and those here who display consumate programming skills and use Python, JSON, PHP, Perl, Ruby, shell script, etc. Speaking purely personally, I'd be really interested in seeing analysed workflows which use Alfred utilities and only installed macOS languages in interesting and innovative ways. (I appreciate the limitation to installed languages is limiting but I think I'm at the stage in my life I don't really want to start learning another programming language—at least to the extent of downloading and installing a new one!).

     

    I do appreciate the audience for this sort of thing may not be large (too much for some, too little for others) but I do think there may be some scope for sample workflows analsyed in detail to help those of us whose imaginations may need a poke!

     

    Apologies for the length of the response.

     

    Stephen

  10. 41 minutes ago, PBear said:

    Why and how can I correct that ?

    As to "Why" I'm sorry but I don't know and will have to leave that to somebody else. However, you should be able at least to have the entry you want at the top of your search results by repeating the search a few times and always choosing the correct result. Alfred will recognise that is the result you want and in future it should appear at the top of the results.

     

    Stephen

  11. Sorry, I'm not Vitor but one way to copy the contents of a file to the clipboard is to create a new workflow using a Universal Action trigger, link to an Automation Task set to "Read File Contents" (which you'll find in Automation Tasks under "Files and Folders") and link that to the "Copy to Clipboard" output.

     

    Edit: Actually, it's better to start with a File Action, rather than a Universal Action—because you can limit the File Action to file types the contents of which can be copied to the clipboard. The workflow will still show as a Universal Action when you trigger it, with the Universal Action shortcut, on the relevant file type.

     

    Stephen

×
×
  • Create New...