Jump to content

Copying multiple feedbacks to clipboard


Recommended Posts

I've write a simple run search on a dictionary website. The input could be one word or multiple words. In latter case, the workflow would generate multiple feedbacks about the meaning, pronunciation and other infos. I use this workflow to learn fresh words by copying the outputs to my note.

 

My problem is: for convenience, sometimes I would copy one sentence as input while there are only a few words I really want to search. Now I use the output action "copy to clipboard" but it can only copy one item at a time. I have to run the workflows many times to finish my work, which is very time-consuming.

 

I am wondering if there is a way to copy multiple feedbacks to the clipboard at one time. 'cause then I can pick them in the clipboard without running the same workflow again and again.

 

Thank you.

Link to comment

I'm assuming you're using a Script Filter. I can think of several ways to do this, but the method I think would be best is as follows:

  • In your code, save a .txt file (in the workflow's cache directory) for each word result.
  • Add type="file" to each <item>. Set the arg attribute to the path to the respective file saved in the cache directory.
    • Why? This will allow you to add the results to the file buffer. By default, ⌥↑ or ⌥↓ will add files to the buffer.
  • Add a Run Script object between your Script Filter and Copy to Clipboard object. Set this Run Script object to read every path in {query} (remember they're separated by tabs), concatenate the text together, and output the text.
  • Add a File Action object that accepts multiple .txt files. Connect it to the Run Script object from the previous step.
    • Why?
      If you only want one definition, you can just hit enter, which will read the text from the single file (specified in the argument of the result you chose) and spit it out.
      If you want multiple definitions, you can add the appropriate results to the file buffer, hit ⌥→ (opens the action panel), and choose the File Action specified earlier. This will cause the script to read each file, concatenate the results, and spit out one string for copying.

This description may be a little abstract without an actual workflow. If you want an example of what I've described, let me know and I'll see what I can whip up :)

Link to comment

I'm assuming you're using a Script Filter. I can think of several ways to do this, but the method I think would be best is as follows:

  • In your code, save a .txt file (in the workflow's cache directory) for each word result.
  • Add type="file" to each <item>. Set the arg attribute to the path to the respective file saved in the cache directory.
    • Why? This will allow you to add the results to the file buffer. By default, ⌥↑ or ⌥↓ will add files to the buffer.
  • Add a Run Script object between your Script Filter and Copy to Clipboard object. Set this Run Script object to read every path in {query} (remember they're separated by tabs), concatenate the text together, and output the text.
  • Add a File Action object that accepts multiple .txt files. Connect it to the Run Script object from the previous step.
    • Why?

      If you only want one definition, you can just hit enter, which will read the text from the single file (specified in the argument of the result you chose) and spit it out.

      If you want multiple definitions, you can add the appropriate results to the file buffer, hit ⌥→ (opens the action panel), and choose the File Action specified earlier. This will cause the script to read each file, concatenate the results, and spit out one string for copying.

This description may be a little abstract without an actual workflow. If you want an example of what I've described, let me know and I'll see what I can whip up :)

It's clear enough, thank you! I'm currently working on reading saved text files part...

Link to comment

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...