Jump to content

vitor

Staff
  • Posts

    8,495
  • Joined

  • Last visited

  • Days Won

    708

Posts posted by vitor

  1. Welcome @sebastianp,

     

    9 hours ago, sebastianp said:

    Maybe some of you can try it out and help me add more stuff to it?

     

    In order to get submissions, you should post the contents of the Workflow on GitHub as well. That’s how people will be able to make modifications and directly send them to you for review.


    Quick note: there’s little point in zipping .alfredworkflow files because they are themselves zip files with a modified extension.

  2. No, with a Script Filter you can have your entry say anything you want. There’s no difference between returning one result or multiple; technically you don’t need your Script Filter to filter anything. It’s the only way to execute code as you type and have it programmatically show up in the results.

     

    The exact implementation will depend on your Workflow. Right now we only have a vague description, without seeing it it’s not possible to be more precise.

  3. 15 minutes ago, cliaz said:

    why is the following approach bad (or not recommended, as you suggested AppleScript)?

     

    On the contrary, that is the way I recommend! It’s easier to implement correctly.


    Note my comment above:

     

    On 4/15/2020 at 5:12 AM, vitor said:

    If you go the Hotkey route, you can be done in under two minutes.

     

    “The Hotkey route” is as simple to implement as the File Action route you demonstrated.

     

    The AppleScript route is more convoluted (emphasis added):

     

    On 4/15/2020 at 5:12 AM, vitor said:

    If you really want to go the Keyword route, (…) AppleScript, which can be a pain to manage.

     

    But it is necessary if you want to use a Keyword in this situation and not a Hotkey or File Action. And @ilium007 did really want a Keyword.

     

    I gave my opinion on what I consider the most practical way and explained why. But I know people have different preferences, and sometimes you just want to do it the way you want to do it, so I also gave the answer on how to do that. This way the person on the receiving end considers new possibilities but also gets to go with their original plan if they so wish. I find that to be a kind way to help. Even if the original requester only takes value from one of the solutions, someone coming afterwards (you) may benefit from the other.

     

    31 minutes ago, cliaz said:

    sips is an inbuilt mac tool

     

    I like sips and use it when it’s enough for my needs, But @ilium007 used magick in the request. Suggesting another tool amidst the other explanation would have made the reply more complex than (what I judged to be) worth it.

  4. Welcome @adamwc,

     

    As far as I’m aware, that question has been successfully answered every time it has been asked. You don’t need to do anything on GitHub. The method is covered in both the first and second posts. Both are incredibly short.


    See the post from February 4 for an even shorter explanation. If you don’t know how to change that value, the second paragraph from the second post on this thread explains it.

  5. 8 hours ago, Chris Messina said:

    I previous asked for a standardized way for Alfred to interact with OAuth-protected APIs, but was shot down


    Respectfully, what you asked for was for Alfred to officially support that integration. A standardised (external) way to do it was the first suggestion you got and it was encouraged throughout. Your goal is good, only the implementation was in question.

     

    I accept that a communication failure might make you feel like you were shot down, but the intent was to push up. If an idea I propose has holes or barriers I haven’t thought of, I appreciate being told so I can rethink it in a way that might make it feasible. Having it ignored seems like a worse outcome, but I concede you may have a different view; mine isn’t authoritative.

     

    Who knows. You were involved with OAuth and have taken up coding recently, so an eventual solution might come directly from you of benefit from your input.


    Thank you for not getting discouraged and pointing @wrjlewis at good examples.

  6. 7 minutes ago, luckman212 said:

    I am not using rerun. I am talking about typing in Alfred's box, which causes the script filter to re-execute completely.

     

    I got that, but it should work the same for both cases. From the docs (emphasis mine):

     

    Quote

    Variables can be passed out of the script filter within a variables object. (…) Secondly, any variables passed out of a script will be passed back in as environment variables when the script is run within the same session. This can be used for very simply managing state between runs as the user types input or when the script is set to re-run after an interval.

     

    7 minutes ago, luckman212 said:

    I can share my workflow if you want

     

    Sure. If you’ve tried the above and confirmed it’s not working, I’ll take a look and try to understand why.

  7. Nice rundown of your issue. Makes it clear to follow along.


    When bumping into this type of problem, check Alfred’s debugger. I bet you’ll find a message about not finding npx. Simplest solution is to call it via its full path, like you’re doing with open.


    See Understanding the scripting environment for a through explanation of what is happening and other ways to fix it.

  8. There is an efficient solution to this, which I use in RecentlyAdded.


    For clarity, I’ll use ENV[varName] when referring to an environment variable, and varName when referring to a variable (or preferably constant) in your code. 


    1. Check if ENV[uidSeed] exists.
    2. If yes: make uidSeed with the contents of ENV[uidSeed].
    3. If not: make uidSeed something unique. Good pick: random number. Better pick: current date (year, month, day, hour, minute, second).
    4. When you output your Script Filter JSON, append uidSeed to the uid of every item and add it in variables.


    What this means is that if your Script Filter was just launched, the steps above will execute 1 → 3 → 4. But on every rerun, it will be 1 → 2 → 4. This creates what you seek: results which are aware of themselves only during the current session.

  9. Make a Workflow. Connect a Snippet Trigger to a Show Alfred utility with Argument s (note the space at the end) and you’re done.


    For the second part of the request—which apps to exclude—you have two options:


    The simplest is to define them in the Snippets feature itself (click “Auto Expansion Options”).


    The other is to make it specific to your trigger in the Workflow. The Snippet Trigger has a Focused App Variable checkbox you can tick which will tell the Workflow which app you were in at the time. By combining that with a Conditional Utility, you can control which apps it triggers on or doesn’t. To get the bundle ID of the apps you care about, after ticking the box connect a Debugger Utility to the Snippet Trigger; from then on, the debugger will show which app you were on at the time you triggered the snippet.

  10. 1 minute ago, niels_bom said:

    Can Alfred be configured to do this in a smarter way? Like 1. open the browser, 2 tell the single browser window to navigate to the given URL.

     

    The way Alfred does it is the smarter way, because it does not interfere and lets external tools define their own behaviour. The alternative would entail writing code for every web browser, keeping it up-to-date with their changes, and it wouldn’t work for browsers which don’t have proper automation support (most notably Firefox).


    You can get the behaviour you seek via a Workflow. That won’t affect Alfred behaviour outside the Workflow itself, and that’s how it should be because it’s more robust, especially if problems arise with your solution (because they will be contained).

     

    I cannot reproduce the behaviour reported by @mudz or yourself, nor have I gotten a response regarding the “Try this” in the previous post, nor the versions of web browsers, Alfred, or macOS this happens in. Without those it’s not possible to give a definitive diagnose or provide the best solution.

  11. 3 hours ago, oldcai said:

    I can be the new maintainer of this plugin or request a PR to your repo.


    I’ll gladly review a PR but don’t intend to transfer ownership of the Workflow.

     

    You can also fork it for yourself but if you do change the name and icon so there’s no confusion of intent or origin.

     

    While the code is open-source and you can use it as you like, neither the name nor the icon are. Also, your mention of “and is now maintained by @oldcai” makes it seem like I officially gave your version my blessing to continue the work, but that is not the case. I have no reason to distrust you but I also won’t approve code I didn’t inspect. Please don’t reuse the externally identifiable features.

     

    Thank you. Looking forward to the PR and to talk about the API.

  12. As @Vero mentioned, doing this properly with AppleScript is the way to go. Otherwise you’re doing GUI automation which can be finicky—if your Mac suddenly becomes slower or unresponsive, the actions you sent may not all go through, leaving you in an unpredictable state.

     

    That said, I gave this a thought and you may not have a choice.

     

    On 2/13/2022 at 4:06 AM, alexxhenry said:

    And 2, this hotkey will still work when in any applications Save dialogue that used the Finder save window. 

     

    That requirement throws away other possibilities because now you have to interact with every conceivable app, and not every app is scriptable. So GUI automation, a last resort, is your only option for this.


    This should work. Edit the Copy to Clipboard with the folder path you want. But see how it relies on ⌘⇧G: it assumes you kept the default shortcut. Also note how there are a few delays between objects: you’ll need to increase those if the actions are too fast for your machine. Those are the disadvantages of GUI automation. That said, this one is simple enough that you’ll probably be covered.

×
×
  • Create New...