Jump to content

Selecting nth result in list


Recommended Posts

Posted

A question from a newbie to creating workflows: Within a workflow, how do I automatically select the nth result in an Alfred result list? So, the first step in the workflow is to enter a keyword in the Alfred window and a certain argument. That argument will produce a certain results list, and I know what it will be (what will be in the first slot, second slot, etc.). I want the workflow to then automatically select the nth result for me (the way I would click on that result, or select command-n, from outside the workflow) and then immediately move onto the next stage of the workflow. Is that possible? If so, how do I do it? 

Posted

Because we want to avoid an XY problem, could you expand on what the goal is (as opposed to the method)? As in, what’s the workflow doing and why do you want that? From your description, it doesn’t seem like you want the item to be selected, but rather that you want the output from that result. In which case, if it’s your own workflow, the solution should instead be to cut the intermediary and send the output directly.

Posted

I definitely see the potential for an XY problem, though it may be unavoidable here. I'm trying to alter an existing workflow that makes flashcards. It takes a long time to enter the flashcard material, because the original workflow has you select from the results list it produces in Alfred (front side, back side, tags, etc.) and then input and then enter and then return to the results list and again select the appropriate field and input and then enter--for each field--and then to enter a new command to create the card. (It's also a bit buggy so one often has to do this a couple of times.) I'm trying to find a way to use a split variable to just enter one string that fills in all of the fields at once (e.g., "Front,Back,Reverse,Tag") and then automatically creates the card. I'm not 100% sure how to do it yet (I know how to make a split variable, but not how to insert it into the original workflow) but this appears to be one piece.

 

Surely it would be easier for me to just alter the scripts within the original workflow, but I'm not that advanced with Alfred yet. (And I can't ask the creator because the workflow has not been maintained since 2019.)

Posted

In that case, a feature to select the nth result wouldn’t help either, because that’d have to be part of the workflow itself and by that point you no longer need it. Without seeing the workflow in question it’s not possible to offer a good alternative, but you’re almost certainly going about it the roundabout way. Instead, find where and how the workflow stores its data. It makes more sense and should be faster to find whatever files it uses and change those by hand.


As for the original idea, you can try using the Dispatch Key Combo Output to press ↓ the required number of times. It’s a janky solution so I don’t recommend it (the idea above is better) but could work. Also, delays are your friend when automating GUIs.

Posted

Thanks so much. Can I ask how I would go about finding where a workflow stores its data? Is that likely to be only on the workflow's Github site, or can I find that somehow within Alfred? 

 

(And yes I was thinking about using Keyboard Maestro to do this, but I've had a lot of issues with its delays being inconsistent.)

Posted

I mean where it stores the data on your computer. Once you make a card, it has to store it somewhere. Again, I can tell where unless you share the workflow. But if it’s well made, it will probably be in ~/Library/Application Support/Alfred/Workflow Data then whatever the workflow’s bundle identifier is (you can find it by double clicking the workflow’s name on the list).

Posted

Oh, sorry, the workflow is Alfred Anki. I think I found its data in the Application Support folder, per your directions, but it doesn't look like I can change anything in there to make the workflow work as I wish. I see the result list that the workflow produces (front/back/reverse) but I'm not sure it would help to edit that.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...