Jump to content

GuiB

Member
  • Posts

    366
  • Joined

  • Last visited

  • Days Won

    19

Posts posted by GuiB

  1. To paste text from a workflow you can use the "Copy to Clipboard" Ouput object, write the content that you want in the text field (where it's written "{query}" by default) and check the "Automatically paste to front most app" toggle. You can also check the "Mark item as transient in clipboard" if you want that Alfred clear this content from the clipboard

  2. 13 minutes ago, deanishe said:

     

    I mean natively, as in multiple text items on the clipboard.

    Ah, you were asking me if I know a way to put multiple text items on the clipboard natively! Not that I know as well. That's why I'm preprocessing the selection. There's text editors that allow to have multiple selection, but I think they all copy with a newline delimiter between selections, so we can't be sure if it's simply a multiline item or a multi-selection.

     

    However, one way I can think of that could be used natively in Alfred (sorry, again a new feature request ;) ) would be to have a Text Buffer. In short, like the File Buffer with Opt+Up arrow to add an item to the buffer and other shortcuts. This would be useful in the Clipboard History viewer where we could select multiple items and send them to the Text Actions at once. We can already send an item into the Text Action from there, so it would be a way to send multiple items easily.

  3. 3 minutes ago, Andrew said:

     

    This is a great full example of an enhancement request, simple and clear.

     

    Could you give an example of a use case for "Only on mutli-argument query" as this hasn't been asked for before with the File Action in Alfred, but I know that actions will be used much more from this point forward.

     

    As an example, if you look at my workflow posted just above, I have an action that sort the items of the multi-argument query. So, I would prefer those actions that works on multi-argument to not appear on single argument query since they won't do anything. I mean, actions like:

    • Sort items (where each items is an argument to the multi-argument query; if the argument is single, then nothing could be done here)
    • Same thing for: Output items as numbered list or lettered list. If there's simply one item, then this won't be useful
    • If each line is a paragrah and we want to insert something between (ex: insert a markdown line"---" between each paragraph), then it won't be useful if there's only one paragraph

    In short, this could be useful to tidy our list between single vs multi-argument query.

  4. 3 hours ago, deanishe said:

     

    How do you get multiple text arguments?

     

     

    By splitting the query using a Run Script action.

     

     

    1 hour ago, Vero said:

    If there's one thing you could do to help us make this process even better is to share your feedback in a structured and succinct way, e.g. a focused sentence or two on the feature suggestion, and a short paragraph explaining your use case.

     

    Yes, sorry @Vero and @Andrew, I know I'm not always succinct as I may be trying to explain a little bit too much my idea, I'll try to make it shorter next times ;)

     

    However, I thought that a workflow would be even clearer... so here is one where I try to explain my ideas: https://d.pr/f/O2e7T7

     

    In short, I'm showing my idea on:

    • Splitting a query to pop the multi-argument text action list and manipulate the array (here I'm doing a sort items)
    • Showing by first passing from a Single-Argument text action or passing directly with a HotKey
    • Showing my idea of how a workflow object could split the query to make it easier for everyone to pop the multi-argument text action
    • Doing an action with a predefined delimiter to use for the split (ex: using newline "\n")
    • Doing the same action, but making it more universal by asking the user for the delimiter to use to split the query and saving it as a workflow environment variable to use it again while joining back to a single argument output

    While doing this, I thought it would be great to restrict the action to appear only in a Multi-Argument Text Action list. So it could be great if the "Accepts multiple argument" parameter of the Universal Action trigger could be a drop-down menu with the choice to appear on:

    • Only in single-argument query
    • On single and multi-argument query
    • Only on mutli-argument query
  5. ok, here is another one! There’s a problem with the forward slash ‘/‘ (more specifically on Text Actions). I mean, we are getting this:

     

    • Multiple slashes are truncated to a single slash. Ex: ‘a//b’ or ‘a////////b’ result in => ‘a/b’
    • When the slash is the end of the string, then it is completely removed. Ex: ‘a/‘ or ‘a/////‘ => ‘a’
    • When the string is simply multiple slashes, then we are getting the File Action at the root directory. Ex: ‘////////‘ => File Action at ‘/‘

     

    I guess it’s because the Universal Actions are based on the File Action code and there’s a pre-processing there that try to filter the forward slash

     

    Also, I was wondering if the conversion from a multi-argument query passed to a workflow object that returns a single argument (single string) could be customized. I mean, at the moment the items are returned with a tab as delimiter, which could be fine with files, but with a Text Action it is not possible to know if the query was first a single argument with tab(s) inside or a multiple argument that was transformed to a single tab delimited string (but if we pass the query first into a script that determines that multiple arguments are presetn). One way I’m thinking that would be great to overcome the tab delimited string would be to make the delimiter customizable by adding a workflow variable that could be dynamically modified. This way, we could define a delimiter that has less risk of interfering with the content and that we could pass the workflow variable to other workflows by passing the environment variable through a Call External Trigger and that could then be retrieve there.

     

    One last point, sorry this is again a feature request, but I think it could be worth it. I think it could be useful if we could force the query to be interpreted as a specific Universal Action type. I mean, for example, in case that we are sending a URL to Alfred, but wish to run a Text action on it. For sure we could set the action to work on URL and Text, but I think the point of having File/URL/Text actions is to better group our actions for specific situations or we could simply have Text actions that work with everything… How I could think to implement this would be to add a parameter to "Force interpretation to: [select type: File/URL/Text]" inside the "Action in Alfred" workflow object and also having a shortcut to switch between different Universal Action type while being inside the Universal Action popup. I mean, like in the Alfred File Browser popup we have the "Hide Preview Panel" and other shortcuts (having the menu would be great as well to learn the shortcuts.

  6. Hi!

     

    While playing I wanted to see how Alfred will represent an array of strings sent to the Universal Actions (as a multiple Text arguments). At the moment it works, but it's only possible by using AppleScript/JXA since we can't split a string from Alfred. See my feature request here:

     

    For now we get the "Email to..." and "Email" actions and we can create some for ourselves. This is great, but the problem is with the preview on the right since it only shows the first text from the array, so we can't preview the complete list. Also, the words and chars count only represents the first item and there's no count of items at the top left of the popup like we have with a File Action (ex: "2 files selected")

     

    *Note: I guess we have the same problem when actioning with multiple URLs, but I can't test because of the bug from my post above

     

    ----

    Edit just to add a small script as example if anyone want to test:

     

    From AppleScript:

     

    tell application id "com.runningwithcrayons.Alfred" to action { "Bonjour", "Alfred!" }

     

  7. Alfred workflow objects can work on array. For example, selecting multiple files in Finder and calling a "HotKey" trigger with a multi-selection will pass the files to an "Action in Alfred" workflow object and this latest object will interpret the passed query as multiple files (like an array).

     

    However, when this query is manipulated and then moved back in Alfred domain from an object that only allows a single string return type (like the return of a "Arg and Vars" object or when we set the query into an environment variable) then this multi-argument query is converted to a single argument query with the items concatenated to a single string delimited with tab. Which is fine since this is a restriction from those methods, but then the problem is that we can't make use of the Alfred workflow objects that can interpret those multi-arguments query since it is now passed as a single argument.

     

    We can work around this by using a "Run Script" and splitting the string into an array and then call from the script the wanted Alfred action using AppleScript or JSX, but we can't move back to chain into another Alfred workflow object or we need to do the same procedure with another "Run Script" and call from inside.

     

    Therefore, it would be great if a new Workflow object could be created or the "Split Arg to Vars" could be modified to allow to output and pass a multi-arguments query to a chained object. For example, this would make it possible to pass an array of strings to be used by the new Text action with the "Action in Alfred" object and make workflows specific to array of strings. Also, this could make it easier for people to receive a value from an "External Trigger" and split it and use the standard Alfred workflow objects.

  8. 1 minute ago, deanishe said:

    If you just echo the arg in a Run Script, you should end up in the same place regardless of whether you used External Trigger or AppleScript: Alfred will interpret the JSON for you and set any workflow variables defined in it.

    You mean, to send the complete JSON string as argument to the "run trigger" then yes you're right, but I think it would be easier with a simple boolean value that would ask Alfred to send the environment variable then building the JSON string from AppleScript and as you said, it's not the best language for this so that's why I thought of passing a smaller part of the JSON string, but yes I would prefer not having to do it and simply asking with a boolean value.

     

    I'll try to change my script to JavaScript for automation to make it easier to build the JSON string for the argument!

     

    Thanks!

  9. The "Call External" workflow objet allow to pass the environment variables to the called workflow. It would be great to be able to do the same when calling it from AppleScript.

     

    It would be great to simply add an option (ex: "withEnvVar" that when set to true the environment variables will be sent to the called workflow trigger. If it's a problem, then the "withEnvVar" could use a string that would represent the JSON value for the "variables" section of an Alfred JSON configuration like:

     

    {
      "alfredworkflow" : {
        "arg" : "{query}",
        "config" : {
        },
        "variables" :  withEnvVar_will_represent_this
      }
    }

     

    In other words, a "withEnvVar" could use a JSON string like:

    "{ \"focusedapp\": \"com.apple.finder\" }"

     

    We can send a full JSON string to the "with argument", but we then need to interpret it on the called workflow which make it problematics if we want to be able to call it using both method: one workflow calling the other from AppleScript and another workflow calling the other but by using the "Call External" workflow object.

  10. 3 hours ago, Andrew said:

    Thanks for all the feedback - Just remember that this is a new feature, and I actually have tonnes of stuff lined up to improve and enhance it over the coming releases :)

    Dear @Andrew, yes we know! I'm just brainstorming a bit to try to get the most out of this feature and give ideas in case you would like to implement them at a point :) 

     

    And actually, I just updated my workflow to implement all of my ideas and I got it working in a way that is modular based on the front application as well. So, I'm happy with the result! I'll try to find time to upload it somewhere with some documentation so everyone can have a play with it, but, in the meantime, I found a bug :) 

     

    In short, when calling the Universal Action from AppleScript, Alfred interpret URL has simple string, so we are getting the Text Actions when we select Text as well as URLs.

     

    For example:

    We are getting the Universal Text Actions list with:

    tell application id "com.runningwithcrayons.Alfred" to action "https://www.alfredforum.com"

     

     

  11. While I'm at it... here is another feature request for the Universal Actions!

     

    It would be great to be able to programmatically run a Universal Action, I mean, without popping the actions list. This way, we could create hotkeys that directly trig an action.

     

    One example, one file action that I'm using a lot is the "Open with..." and I think it would be great to be able to assign a hotkey that would directly activate this action so I would directly get the list of applications to open the file with instead of needing to select the action first (or doing it with a script that automates typing).

     

    The way I'm thinking of implementing it would be to add a "directly run action" parameter inside the "Action in Alfred" workflow action and where we could get the list of available actions from a drop-down menu. In short, like the "Workflow Triggers" button inside the "Call External" object.

     

    With that, it is already possible to connect another object after the "Action in Alfred". However it is run directly when the UI pop at the moment. I think it could be an option to make it blocks until the user has selected an action so we can run something after sequentially (maybe having a parameter to specify if we want to run in parallel or sequentially would be useful). This way (and with the possibility to directly run an action) we could chain multiple actions together to make it easy to build workflows with small parts from different workflows and that chain together in the order that we want. I mean, we could do something like: User select a piece of text then run a workflow that do [ "Action: Extract URLs from Text..." > "Run Script: That filter to a specific kind of URL" > "Action: Save as Snippet" ]

     

    This could be used as an alternative to the "Call External" object, but where the workflow that is called doesn't need to know the caller and calling it with a specific "Call External" object to return the result since the "Action in Alfred" object will encapsulate the input and output of the workflow.

  12. From everyone replies, I think we all always want more extensibility :) 

     

    @Andrew, I had a play on my side and actually I'm able to get what I want (with the pre-processing of the input) by calling the Universal Actions from a workflow triggered by a Hotkey (so, like I did before, but now I can get a universal actions list instead of a specific workflow when actioned with a string). Right now, I set a condition that if there's no input then I run my script to try to get the file or the URL from the front application and then pop the Universal Actions with the found value or run another workflow if there's still nothing found.

     

    So, I would say that I'm good with my request :) It would be great to make it faster to have it natively inside Alfred, but I think the workflow object makes it customizable quite well.

     

    I don't know if you are trying to build something in this regards during the last days, but if so I'm sure it's going to be great and if not then I'm good with my setup!

     

    To get back to @nyc2cal, yes maybe some extra usability options could be great. I also found that with the "Workflow Keyword Inputs" and "Workflow Script Filters" ticked I have a very long list of actions, so I unchecked them at the moment and find it better. However, I think it would be great to be able to configure it more than to set it to all or nothing since there's some workflow I could benefit having there. So, what I'm thinking is maybe it could be great to add an option to the Keyword and Script Filters objects to specify if we want it to appear in the Universal Actions list or not. With that, in the Universal Actions preference, instead of having toggles, it could be a drop-down menu for those 2 types (Keywords + Script Filters) to specify if we want "all of them", "manually activated inside workflows" or "none". I know we can add the Universal Action trigger inside a workflow for that, but I'm wondering how we could disable/activate it when imported from a downloaded workflow (actually, this is something that I think would be great to add to every workflow objects: being able to disable/bypass it so we could tidy our list of actions that appears in Alfred)

     

    With that, what I've been thinking that would be great is to add an option to the Universal Action trigger to make it active or not only in specific applications. I think it would be great to add the same "Related Apps" section as the Hotkey trigger so this could be a way to tidy our list and it could be a way to create specific actions list per application (some kind of a command palette) and this could be a way to create and share workflows that "augment" each other to build a list for a specific application.

     

    Those are simply some ideas since I think we will get used to filter our list with our input like we always did with the File Actions or the standard Alfred input field, but maybe this can spark you some ideas :)

     

    One other point, not sure if it's a bug or not, but I've been thinking that some kind of a tagging feature could be great and be used to filter a list to items tagged with the same tag. So, what I've thought was to append the same text to the action titles that I wanted to group (ex: "Copy as Plain Text                     [ @text ]" ; with many spaces to try to hide the tag in the action list, just tried inside a workflow and actually the tag doesn't get hidden since Alfred truncate the middle of the string and not the end), but whenever I modify the text and press Enter then the string revert to the default one. I never tried to change the Default Actions titles so maybe it has always been this way, but I'm questioning why are we able to get a text input field if it's not to modify the title then?

     

    One last thing, it is already mentioned at the bottom of the Default Actions list that some actions will only show depending on context, maybe those contexts aware settings could be editable and could be added to the Universal Action trigger?

  13. Great new feature! Actually, I did a workflow that does that a long time a long ago that replaced the File Action with a custom Hotkey action that would detect if a file was selected or simply text or nothing and invoke the File Action or a custom workflow that give me a list of text processing actions or a custom script that would try to get the opened file from the front window if nothing was selected and then pop the File Action on the file that the script found.

     

    With this new feature, I can get the first 2 actions, but what about when nothing is selected? I understand this is maybe a bit counterintuitive, but I think it would be great to have a "fallback actions" list that would pop when nothing is selected so we could add some pre-defined actions that could be invoked to run a specific script in those circumstances... On my side I would even like to have a "pre-process" script that could be run so I can see if I can automatically run a specific script and if it doesn't get any results then it would pop the fallback actions list.

     

    Actually, by reading the text in the "Universal Action" trigger, I got the impression I could get an action that would be in the list all the time. I mean, it says: "Only show this trigger when the input argument match the type." , so I was thinking that if nothing was selected from the toggles above then it would be listed all the time since the input wouldn't match "only" the any of those types... So, I think it would be less confusing to remove the word "only" from this sentence (maybe just for myself ;) ) or to make it act like the action will appear in all the types. This could work as some kind of fallback actions, but this would be different than having an action list when nothing is selected as I said in the above paragraph... I think I would prefer to have a specific parameter for the fallback action since now I find it greats that we can "disable" the trigger by unchecking all the toggles (I'm thinking regarding when installing a downloaded workflow where I would disable this universal action on my side).

     

    I'm not sure if I'm completely clear, so please let me know if I’m not explaining it well! ;) 

     

    With that said, thanks for this new feature! It is already really great how it is and seems to work great at the moment by playing with it a bit!

  14. 6 hours ago, Nabil said:

    Im talking about the second line!?

     

    Actually, you don't need to edit that line. The `filePath` string that is mentioned here is simply a variable that refers to the `filePath` string from the first line.

     

    I mean, the first line is simply there to set a variable to the file path that you want and then this variable is used later in the script. I put it there at the top so it is easy to see and make it clearer.

     

    Hope this helps!

  15. On 2/24/2020 at 2:48 PM, Nabil said:

    how do I find the POSIX file path? As shown in the script description for the workflow! 

    I am an amateur!!

    @Nabil, for the script, you need to change the `"/path/to/your/image"`  in the line:

     

    set filePath to "/path/to/your/image"

    to the path of your file.

     

    You can get the file path using the Alfred File Action named "Copy Path to Clipboard" or the 'Copy "fileName" as Pathname' that you can get while doing a secondary click on the file in the Finder and holding the Alt key  (like explained here: https://osxdaily.com/2015/11/05/copy-file-path-name-text-mac-os-x-finder/ )

  16. Hey, a little late, but wanted to join the party since this is one of my most wanted feature requests (I think we talked about this multiple time ago...)! Actually, it would be great to remove the restriction completely and allow to assign the same hotkey in any workflow and make a popup to list the possible list of actions when invoking a hotkey which is assigned to multiple actions (like @Jasondm007 is mentioning), but being able to use the same hotkey only in app-specific situation would be a great step! :)

     

    I've been assigning some of my hotkeys from behind (by editing the workflow "info.plist") or using BetterTouchTool or Hammerspoon to get around this.

     

    On 1/17/2020 at 6:22 AM, Andrew said:

    I'm open to implementing this.

     

    One of the reasons this hasn't been a thing so far is it is much easier for users to accidentally get themselves into a confusing situation. What would you consider to be the desired behaviour if there were a hotkey conflict? (e.g. set same hotkey on two different synced macs in different workflows, which when the sync merges, they are both "valid").

     

    I think the idea to pop a list of the actions that are linked to the invoked hotkey would make it work and would clearly show that we have a conflict, but the wanted action could still be invoked from the popup list. Maybe to make it even clearer, you could add a little mention on the popup that specifies that multiple actions were found using the invoked hotkey...

     

    For the popup, what I'm thinking is to just pop the normal Alfred search UI, but with the list items set to the conflicted actions (so we can invoke one using CMD+1 or CMD+2 ... or writing its title to filter the list). The problem I'm thinking is how can we get a title, but the Hotkey object doesn't have one... maybe you could use the Workflow Title and with that, maybe you could add a "Label" field to the Hotkey object or use an Object Note as title? With that you could set the item icon to the Workflow icon or add an icon field to the Hotkey object... Maybe those new fields could be grouped and mention that they would be used in case of hotkey conflict.

     

    I know this may be quite some work to implement the feature, but I think this would be worth it and I think it would actually make it less confusing to every user (new and more experimented ones; I think there were multiple messages here on the forum regarding the confusion of a user regarding why it couldn't use a specific key combination and then later found out it was already used somewhere else). Also, this could be used to implement some kind of modal keybinding.

     

    To give some more idea... To make it easier to fix those conflicted hotkeys, when on this popup you could set a modifier key that would jump to the selected hotkey object node in its workflow. This way we won't have to search too much to find where it was set.

     

    So again, just my +1 :)

     

     

  17. @Jasondm007, yes that would be great to be able to call directly the File Action, but at the moment I think the only way is doing GUI scripting using AppleScript like @deanishe said or you can implement your own version of the built-in actions using a shell script or AppleScript.

     

    For the Open With, if you want to avoid the GUI scripting route, you can easily do it using a shell script like:

     

    open -a "ApplicationName" /Path/To/File

     

  18. @Jasondm007 

    honestly I don't have many tricks for trying to get some outputs to the debugger and carefully looking at the information there. Sometimes I look at what is happening before, sometimes after a node, trying to output a variable and analyzing it to see if it's right, adding tests inside the script to try to pinpoint where the problem occurs (see if a loop is looping correctly, if a variable is set correctly...)...

     

    In this case, you could see that from the "imc" Keyword node a string was output with paths separated by tab, but on the "Image..." File Action node you could see that the paths are separated by "comma" in the debugger (if you connect the Debug node just after the File Action). This way you have a little cue that the outputs are different. Then you can inspect the "item 1 of argv" and see if they match and if not try to find out why they are different.

     

    With that said, keep in mind that from an Alfred node that output a list of items you would get a List, but when chaining multiple nodes (different Run Scripts or other actions) one output is passed to the next node as one string. So, in order to get multiple items we have to build this string we can manipulate it in the next node to retrieve the different items (that's why I'm passing the paths with tabs as separators as a trick to pass multiple items so we can easily split them afterward in the next node). You can use any delimiter that you want of passing JSON string or something else (like we talked on this thread:

     

    To get back to your workflow above, actually you don't have to pass the output of your AppleScript from your "imc" keyword node and depending on what you want to achieve it could be easier to directly loop over the selection list that you get from the Finder instead of modifying the list to a single string with tab delimiter (especially if you want to connect it to another AppleScript). Here is a modified workflow to show you how it looks if you use the selection directly: https://d.pr/f/pvtilq

     

    Also, I don't remember exactly why I added the Trim function to make sure to trim the files path (maybe to make sure one of the paths doesn't have an extra whitespace in it in case we output as one string), but if you use the passed list from Alfred file action or the Finder selection, then you shouldn't have to trim the paths.

     

    Hope this helps a bit! :)

     

    Best

  19. @Jasondm007, you problem is that when you are directly connecting to the File Action you are receiving a list of files in "argv", but on the second example ("imc") you are sending a tab delimited list of file paths that consist as a single string as input. Therefore, on your first example you can iterate over the list input of you script and not just the first argument ("argv 1"). 

     

    Here is a modified version: https://d.pr/f/0BOBGT

     

    I added a delay to better make sure the item has time to be copied (I didn't have all the items on my clipboard viewer if not), but you can play with it to make it work for your case.

  20. @cebroski in addition to what @deanishe said, I would recommand to remove also the last part of the scipt so it doesn't close an already opened tab.

     

    I mean, remove:

    -- close the first default tab
    tell application "System Events"
    	keystroke tab using control down
    	delay 0.2
    	keystroke "w" using command down
    end tell

     

    However, if I understand well what you want, I think it would be better/easier/faster to use the Alfred's builtin 'Open URL' object. The idea is to have a Keyword object (or another trigger) that connect to 2 'Open URL' objects that send your specific URLs to Firefox.

     

    Here is an example workflow that should do what you want: https://d.pr/f/jsvmIY

    Make sure to check the "Open links in tabs instead of new windows" in the Firefox Preferences.

  21. @slyfox, yes @deanishe is right about the first example whose passing the Arg & Vars to Alfred, but my second example uses Python.

     

    Here is the workflow updated again: https://d.pr/f/z8i7VM

     

    But to put it here in the forum:

     

    My first one uses an expression in the Arg & Vars (ex: `round(({query}+({query}/0.971))*100)/100` ) and pass it to Alfred using `tell application id "com.runningwithcrayons.Alfred" to search "={query}"`

     

    My second example uses a Script Filter set to the Python language and what is great is that you can see directly see the output. You can just change the expression at `val = round(query+(query/0.971),2)` to use what you want.

     

    Here is the script:

     

    import sys, json
    
    query = float(sys.argv[1])
    
    val = round(query+(query/0.971),2)
    
    data = {'items': [{
        'title': val,
        'subtitle': str(query)+'+('+str(query)+'/0.971)',
    	'arg': val,
        'text' : {
            'copy' : val,
            'largetype' : val
        },
    }]}
    
    sys.stdout.write(json.dumps(data))

     

×
×
  • Create New...