Jump to content

Bhishan

Member
  • Posts

    146
  • Joined

  • Last visited

Posts posted by Bhishan

  1. This might be a very simple question, but I could not find an easy way to assign a keyboard shortcut to run Alfred with another workflow command arguments:

     

    For example:

    In Alfred:   " throw"    command will throw all the contents from the Downloads folder to Trash Folder.  (workflow: Trash Downloads  axelpeigne.trashdownloads)

    In Alfred: "emptytrash" command will empty the Trash contents using Alfred built-in command.

     

    Is there a way to combine these two commands and assign keyboard shortcuts for them?

     

    Required:

    ctrl-shift-E    should run   alfred commands `throw` and then `emptytrash`.

     

     

    My attempt workflow is here.

     

     

    Pesudocode:

    ```

    tell application "Alfred 3" to run command "throw"

    tell application "Alfred 3" to run command "emptytrash"

    ```

     

    Then just prepend a HOT key trigger to this File Script.

    I just don't know the actual AppleScript commands.

     

    Thanks.

     

  2. @vitor  Thanks, now I can move the Fentere in the desktop corners.

     

    I have one follow up question.

     

    When I set up hot key to open Finder file to open with Fenetre, it does takes the file to the menu of Fenetre, I manuall need to go to Fenetre and click the menubar.

     

    Can it be made single workflow a) puts the file to the menubar of Fenetre 2) then opens it in Fenetre?

     

    Thanks a lot!

    fen.png

    fenetre_menu.png

  3. There is a mac app fenetre using which we can make any window and youtube videos at the frontmost app. 

    However, the keyboard shortcuts there works only when the frontmost app is fenetre. 

     

    How to make the keyboard control make universal using Alfred workflow?

     

    For example, <alt-cmd-right> moves the fenetre window to right side. But it only works only when that app is highlighted.

     

    I would like to make it universal.

     

    If it is very time consuming to get all the keyboard controls of fenetre, I would like only to get the movement controls. e.g. only <alt-cmd-right> moves fenetre window right.

     

    Thanks a lot.

     

    I have shared my preliminary workflow here.

     

     

    fenetre.png

    top_fenetre.png

  4. Many times I am running TWO bash terminals at the same time.

    In one terminal I can write code in vim editor,  and in second terminal I can run the code, or do another things.

     

    I was looking if I can have some keyboard shortcut to switch between two terminals, without using mouse.

    cmd-tab will switch through all the open apps, not only two opened terminals.

     

    I was wondering how to achieve the goal.

     

    I have shared my workflow here.

     

    I found a code to activate the current terminal window from any frontmost app, but still looking for code to switch between two terminals.

     

    # Ref: https://apple.stackexchange.com/questions/231112/open-the-same-terminal-without-switching-spaces
    tell application "Terminal"
        if not application "Terminal" is running then
            activate
        else
            if (exists window 1) then
                activate
            else
                do script ""
                activate
            end if
        end if
    end tell

     

    Thanks a lot!

  5. I was trying to write a simple workflow to convert farenheit to celcius and display in alfred using script filter.

     

    Here is the workflow link.

     

    Code:

     

     

    import json
    import sys
    
    
    faren = float(sys.argv[1])
    
    celcius = (faren - 32) * 5.0/9
    
    data = {'valid': 'true', 
             'title': 'Farenheit to Celcius',
             'subtitle': str(celcius)
             }
    
    data_lst = [data]
    
    
    data = {"items": data_lst}
    json.dump(data, sys.stdout)

     

    Problem: It gives following error

    IndexError: list index out of range

     

    How to fix the error?

     

    Thanks.

  6. I have shared an workflow that can be customized to display the world cities of our choice. By default it shows the time of Chicago, Kathmandu, and Brussels (America, Asia, and Europe cities).  To add an city we need to edit the Script Filter, which is fairly simple: we need to write name of the continent followed by / and name of the capital city or the main time zone city if there are more than one time zones in that country. The full list of time zones can be found in this wikipedia page:   https://en.wikipedia.org/wiki/List_of_tz_database_time_zones.

     

    The workflow can be download from packal: http://www.packal.org/workflow/simple-timezone .

     

    Sample screenshot:

     

    timezones.png

  7. Date:  Oct 11, 2018

    Platform: MacOS Mojave

     

    I was running vim in the terminal and tried to use Alfred text expansion, but it does not work there.

    It gives the following error:

    Terminal seems to be preventing text expansion by locking secure entry 

     

    For example, I have a snippet:  ";;dd"  for "date expansion". This works in all other text fields like TextEdit, Notes, and browser pages. But it does not work in terminal editor VIM.

     

    How to avoid this error?

     

  8. I was trying to write an Alfred workflow that will close all the other Safari tabs and also closes all other open safari windows open.

    There is keyboard shortcut  "cmd opt w" which will close all other tabs. But I have to manually close all other opened safaries.

     

    How can this workflow be created?

     

    I have shared my preliminary workflow here.

     

    This is pseudo code:

     

    Sometimes watching movies Safari creates a lot of unwanted tabs and windows, I want to get rid of them and open only current tab.

     

    Thanks for help.

     

    on alfred_script(q)
    tell application "Safari"
        close (every window except this tab)
    end tell
    end alfred_script

     

  9. Link to workflow: workflow_link.

     

    Using the information from this apple stackexchange link, I tried to create an apple script to click the menu "Get LaTeX" from the app called "Mathpix Snipping Tool".

     

    NOTE: The Mathpix Snipping Tool is a great app, it can get the OCR of any image and converts it into LaTeX item.

    Since it is difficult to remember so many keyboard shortcuts, I decided to write alfred keyword to simulate "ctrl-cmd-m" of this app, but got 

    problem and posted the question.

     

    Here is the code:

    tell application "Mathpix Snipping Tool"
        activate
    end tell
    tell application "System Events"
        click menu item "Get LaTeX" of menu 1
    end tell

     

    When I run the first part in terminal using `osascript myscript.scpt` it runs fine. However, when I run the whole code it gives error.

    mymathpix.scpt:94:138: execution error: System Events got an error: Can’t get menu 1. (-1728)

    The application is not a regular application like Safari with menu items, its just hanging in top of the menubar and we can use some keyboard shortcuts to run the commands.

     

    How to fix the problem?

     

    Thanks.

    mathpix.png

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

     

     

  11. Update:  The MWE workflow can be found here.

     

     

    tldr; Needed help using appplescrip to edit string, I know how to do in python.  (The required workflow is working help needed to make it better.)

     

    I was writing an Alfred Workflow to render ipython notebooks `.ipynb` files nicely using nbviewer of github.

    For that we need to use the website: https://nbviewer.jupyter.org

     

    For example to render a ipynb file:

     https://github.com/bhishanpdl/pdl_practice/blob/master/a.ipynb

     

    We need to open https://nbviewer.jupyter.org and paste the above notebook url there.

     

    i.e.

    From: https://github.com/bhishanpdl/pdl_practice/blob/master/a.ipynb

    To:  https://nbviewer.jupyter.org/github/bhishanpdl/pdl_practice/blob/master/a.ipynb

     

    Then, we just need to open the new url in safari.

    ----------

    I did following:

    - applescrip to find frontmost tab url and copy to clipboard

    -  edit the url using python

    - again use applescript to open edited url

     

    This seems to be bit of too much of a work.

     

    Is there way it can be done in only one applescript. The only thing I don't know is how to edit the string in applescript. 

    I am only comfortable working with python and use it for most of the work.

     

    nbviewer.png.7e7c4f6a1a5b2480ce575d56fda9bfaa.png

     

     

     

    The codes used are following:

     

     

     

    # First applescript
    tell application "Safari"
    	ignoring case
    		set theURL to URL of front document
    		set the clipboard to theURL
    	end ignoring
    end tell
    
    
    # Second python script to edit url
    import sys
    query = sys.argv[1]
    query = 'https://nbviewer.jupyter.org/github'+ query.split(r'github.com')[1]
    sys.stdout.write(query)
    
    """
    From:                       https://github.com/bhishanpdl/pdl_practice/blob/master/a.ipynb
    To  : https://nbviewer.jupyter.org/github/bhishanpdl/pdl_practice/blob/master/a.ipynb
    """
    
    
    # Last applescript to open url
    on alfred_script(q)
      set theURL to the clipboard
      tell application "Safari"
        open location theURL
        activate
    end tell
    end alfred_script

     

    How can all these codes can be written in only one applescript?

  12. @dfay  @vitor

     

    This task proved to be too complicated than I initially thought of.

     

    I was just trying to create some hot key that will commit the changes i made in a file in github while working online. Its not a big deal commiting and pushing a file from the local computer to the github online, I was just trying to avoid going to bottom of the page and clicking the green "commit changes" botton each time when working online. It takes just a second but I was looking for alternatives.

     

    Example:

    - open the README.md file online in github website

    - do some changes

    - now hitting some keyboard shortcut should commit the changes.

     

     

    What I can do:

    If I have already cloned the repo locally, I can upload the changed file using some bash commands using alfred.

  13. I am trying to write an workflow that will do following things in github page:

    - go to the bottom of the page

    - click commit button

     

    The main thing is whenever we are editing a file in github online to commit the chages we have to go to 

    the bottom of the page and click "Commit changes" button. The github does not have that button on the top

    of the webpage and also does not have keyboard shortcut to do that. 

     

    Commiting and Pushing edited files from a terminal is pretty simple a simple bash function in `bash_profile` will do that easily, but while working

    on online pages, we need to scroll down each time if we need to commit the changes. It will not save a heavy amount of time but if it is possible,

    the Alfred workflow to do it worth it.

     

    Thanks.

  14. Thanks a lot @vitor

     

    I inserted an

    Utilites > Delay 

    With 2 seconds, it worked for now.

     

    My attempt with AppleScript

    on alfred_script(q)
      tell application "Lepton"
    
    activate
    
    end tell
    
    
    tell application "System Events"
    
    tell process "Lepton"
    
    click menu item "Search" of menu "Gist" of menu bar 1
    
    end tell
    
    end tell
    
    end alfred_script

     

    And, this works. Thanks a lot!

  15. Is there a simple way of opening an app and execute its menu command using Alfred ?

     

    For example, in Lepton app the keyboard combination `shift-space` will do the gists search. I would like to 

    make an alfred workflow to do this search.

     

    Attempt:

    1.  Assign a hotkey 
    
    2. Lauch app Lepton
    
    3. Key combo

     

    However, this will only open the app and does not run the key combo.

     

    Is there a simple AppleScript to do this? Or, am I doing something wrong here?

     

     

     

     

    lepton.png

×
×
  • Create New...