Jump to content

Bhishan

Member
  • Content Count

    137
  • Joined

  • Last visited

Reputation Activity

  1. Thanks
    Bhishan reacted to vitor in [SOLVED] How to Assign Keyboard Shortcut to empty Downloads and Trash Both?   
    @Bhishan You have way too much code. You can do it with
    tell application "Finder" delete every item of folder (path to downloads folder as text) empty trash end tell  
  2. Thanks
    Bhishan reacted to CJK in [SOLVED] How to Assign Keyboard Shortcut to empty Downloads and Trash Both?   
    Yes, I believe so.  You can take the first workflow (`throw`) and append a _System Command_ action, for which you would choose "Empty Trash".  Then prepend to all of this a hotkey that triggers this sequence of events.  No AppleScript ought to be needed.
  3. Thanks
    Bhishan reacted to vitor in [SOLVED] Workflow to control Fenetre application   
    @Bhishan That’ll likely require scripting Fenêtre itself. You need to ask on their forums.
  4. Thanks
    Bhishan reacted to vitor in [SOLVED] Workflow to control Fenetre application   
    Press hotkey (set shortcut to only fire when Fenêtre does not have focus) → Launch Fenêtre (should bring it to the top) → Redo shortcut.
  5. Thanks
    Bhishan reacted to vitor in [SOLVED] Switch Between Multiple Terminal Windows   
    You can cycle through windows of the same app, on macOS. Or open new tabs and do the same.
  6. Thanks
    Bhishan reacted to deanishe in [SOLVED] Could not convert Fahrenheit to celcius in Script Filter   
    Uncheck "Alfred filters results".
     
    If that's checked, Alfred doesn't pass the query to your script.
  7. Thanks
    Bhishan reacted to vitor in [SOLVED] How to use "ESC" key in Alfred output key combo?   
    Why not? Doing it in a Key Combo works fine. It’s unlikely ⎋ (escape) will act as a modifier, so the shortcut is likely ⎋ m (one followed by the other rather than ⎋m (in tandem).
  8. Thanks
    Bhishan reacted to CJK in [SOLVED] How to close all Safari windows and tabs except current tab?   
    Hi @Bhishan,
     
    Here's the equivalent code for Chrome that closes all windows and all tabs except the currently active one:
     
    use Chrome : application "Google Chrome"
     
    property |windows| : a reference to every window of Chrome
    property |tabs| : a reference to every tab of |windows|
    property tab : a reference to the active tab of Chrome's front window
     
    close (|tabs| where its id ≠ id of my tab)
     
    It's very similar to the Safari code, but Chrome requires that comparing tabs is done via their id property rather than directly as object references.
  9. Like
    Bhishan reacted to CJK in [SOLVED] How to close all Safari windows and tabs except current tab?   
    I wish you had asked this in your initial question.  It's extra work to go back and test a script in different situations after the fact, rather than had I known and been able to do the testing all at once.

    I'm too tired to go and test anything for Chrome, but it would involve changing current tab to active tab, and utilising the id property of my tab to exclude it from the enumerated list of id of |tabs|.  Play around with it and just do trial-by-error.  That's what we all do.

    Regarding Firefox, it won't work.  Firefox isn't scriptable (to any useful extent).

    I'll check back in a couple of days and post a working solution for Chrome if you haven't got it figured out by then.

    Next time, please include all your related needs in a single post.  Obviously, very disparate issues are still best posted as separate posts.
  10. Thanks
    Bhishan reacted to CJK in [SOLVED] How to close all Safari windows and tabs except current tab?   
    You could try this:
     
    use Safari : application "Safari"
     
    property |windows| : a reference to every window of Safari
    property |tabs| : a reference to every tab of |windows|
    property tab : a reference to the current tab of Safari's front window
     
    close (|tabs| where it ≠ my tab)
     
    I haven't really tested it though as I currently have a gajillion tabs open that I don't particularly want to close.
     
    Also, don't use the Run NSAppleScript action.  Use the Run Script action and select /usr/bin/osascript (AS) as the chosen language.
  11. Thanks
    Bhishan reacted to CJK in How do I click a menu item of application in Mac menubar?   
    @Bhishan, this is the general form the AppleScript code will take when trying to access a menu bar icon and its menu:
     
    use application "System Events"
     
    property P : a reference to the process named "Mathpix Snipping Tool"
    property M : a reference to menu bar item 1 of menu bar 2 of P
    property I : a reference to the menu item named "Get LaTeX" of menu 1 of M
     
    click M
    click I
     
    It doesn't work for every single menu bar application, and there's an annoying 5-second delay between the first click command and the second.  This is a known, persistent feature that has various documented so-called solutions, none of which are reliable, but you can have a Google and see what works for you.
     
    Don't forget to make sure Terminal (or whichever program is executing the above script) has accessibility privileges granted to it.
  12. Like
    Bhishan reacted to deanishe in How do I click a menu item of application in Mac menubar?   
    I've changed the title of your topic.
     
    [HOWTO] is for explanations of how to do something, not for questions.
     
  13. Like
    Bhishan reacted to advena in Problem with Write Text File using multiple variables   
    Hey @Bhishan--
     
    I decided to post this to the forum in case it helps someone else out.
     
    There were two main things I was doing wrong. First was running each variable on its own thread. For what I was doing, the proper thing to do was to have everything on one thread (and therefore running one after the other).
     
    The second issue I was having was with filters. You'll need to google to understand exactly why it happens (I don't understand it well enough to explain it), but I was having unwanted newlines & whitespace in the output. This meant filters weren't working as I expected (since the input to the filter had newlines etc I didn't know about). That was fixed by using some `Transform` and `Replace` utilities.
     
    I'll attach both of the workflows based around the original workflow.
     
    Hope these workflows help you figure it out
    -Scott
     
    Create a new note with or without selected text with Zettelkasten metadata
     
    Create a new note (with or without selected text) & PDF from Safari tab with Zettelkasten metadata

     
    Screenshots:
     
    New note:
     

     
    New note & PDF:
     

  14. Like
    Bhishan got a reaction from vitor in [SOLVED] Workflow to render GitHub ipynb files nicely using nbviewer.   
    @vitor   Apologies for forgetting to upload the  MWE workflow.
     
      For completeness,  uploaded posthumously:  workflow link
     
    Its sunday evening here in Ohio USA. I was not expecting answer until monday.  The Community of Alfred is awesome!
     
    I know there is one father and one mother of Alfred, I guess there are so many brother and sisters of Alfred who are helpful and active 
    almost all the time.
     
    Sorry for the probable XY question. Rather, I should have explained the problem and seek for the suggestions from the expert.
     
     
    Its always tempting to beliveve that if we know the small part, we can ourself solve the rest of the problem and avoid taking too much time of the helpers. But sometimes it goes the wrong way and instead the asker needs too much time of helper.
     
    Thanks again, the new workflow with JXA works nice and also helps to write further similar workflow.
    I need to look and grab some basic concepts of JXA now.
     
     
  15. Like
    Bhishan reacted to deanishe in Accessing workflow args in bash script   
    No, no, no. It's not my product, dude. Hell, all the worst (best, imo) rants on the forum against Alfred were written by me.
     
    I'm basically the resident dick on the forum. OTOH, for my occasional-to-frequent bad attitude, I'm also one of the most experienced workflow developers and often right…
     
    Sorry if you feel I went off in the deep end in reaction to your "Alfred's not like Linux: it's broken". That was a wee bit passive aggressive on your part, and tbh, passive isn't really my style. You should have seen the first draft of that post…
     
    Seriously, Alfred isn't bash. If you won't accept that, you're only causing difficulty for yourself ('cos it ain't gonna change).
     
    For what you want to do, you should do it the way I suggested. It works perfectly. Otherwise, you'll just be fighting with Alfred.
     
    To back up my claim of shitting on Alfred, the Script box is a terrible editor. No highlighting, no line numbers (which you need to track down inevitable errors), and embedding all your code in info.plist ruins source control.
     
    "What's changed? Info.plist!" Not super helpful…
     
    As a rule, it's a much better idea to put your code in a separate file, anyway (for the above reasons), and treat the Script box like a command line. 
     
    Put ./script.sh $1 (or ./script.sh "$1") in the Script box and the rest of your code in script.sh. It's the smart way to do it.
  16. Like
    Bhishan reacted to vitor in [SOLVED] How to write an Alfred workflow to "go to bottom of GitHub page and click Commit Changes" button ?   
    This is pretty easy to do with AlfredBookmarklet. The only code you need is document.getElementById('submit-file').click();. Here’s a ready-made version.
  17. Thanks
    Bhishan reacted to evanfuchs in [SOLVED] How to write an Alfred workflow to "go to bottom of GitHub page and click Commit Changes" button ?   
    I use a web-based software that is all button clicks with no keyboard shortcuts. Switching back and forth from mouse to keyboard drives me nuts. If the button is visible on the page, Keyboard Maestro's "Click at found image" is good for this sort of thing.
  18. Thanks
    Bhishan reacted to vitor in [SOLVED] How to write an Alfred workflow to "go to bottom of GitHub page and click Commit Changes" button ?   
    You’re going about this the wrong way. Don’t automate the page, use their API. If you understand bash, here’s a simple script that uses their API to merge PRs.
     
     
    This can’t be done with AppleScript. Automating the page requires you to inject JavaScript on the page to perform the actions.
     
    What exactly are you trying to do? Show us an example page and the exact action.
  19. Thanks
    Bhishan reacted to dfay in [SOLVED] How to write an Alfred workflow to "go to bottom of GitHub page and click Commit Changes" button ?   
    Fake.app is the easiest way to do stuff like this - but it may be overkill for your needs, if you don’t want to run the task in a separate browser.
  20. Like
    Bhishan got a reaction from deanishe in [SOLVED] Plot datafiles using Alfred and Python   
    @deanishe   Thanks for the suggestion, it worked now.
  21. Like
    Bhishan reacted to deanishe in Recommendations for Sharing Workflows [Updated 3/26]   
    Not sure if this is quite the right thread, but if you're distributing a workflow written in Python, *do not* ask users to install Python libraries in the system Python. Bundle them with your workflow.
    It's not ideal, but installing libraries into the system Python is very bad form. The chances are good that you'll break some other software doing the same naughty thing—or it will break your workflow—by installing an incompatible version of a library.
    It's trivial to install libraries directly in your workflow with "pip install --target=my/workflow/dir". Do that instead.
    In addition, bundling the libraries with your workflow means the workflow will sync across machines without problems.
  22. Like
    Bhishan reacted to deanishe in [SOLVED] Could not read argument names in File Action   
    Alfred's query is one argument. It doesn't matter if there are spaces in it: it's Alfred, not bash.

    So this bit is broken:

    minute=$1 seconds=$2

    If you enter "5 30" as your query, then $1 = 5 30 and $2 is unset.

    You need to manually split $1 into its component parts with something like:

    mins=$(echo $1 | cut -d' ' -f1) secs=$(echo $1 | cut -d' ' -f2)
  23. Like
    Bhishan reacted to deanishe in [SOLVED] Could not get the user given argument at last part of workflow   
    The problem is that you're trying to store two values in one variable. When your first Keyword element finishes, {query} = 25. Your Run NSAppleScript element immediately overwrites this with the YouTube URL, so {query} = https://www.youtube.com/…

    You need to insert an Args and Vars Utility after the trim Keyword to save the user input to a different variable.

    Here is a working version with the above changes.
×
×
  • Create New...