Jump to content

AvantGardener

Member
  • Posts

    2
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by AvantGardener

  1. For those who prefer Google Chrome over Safari, here's the alternative AppleScript that should enable the same background search features in Chrome:

     

    set myURL to "https://www.google.com/search?q={query}"
    
    tell application "Google Chrome"
    	set activeIndex to get active tab index of window 1
    		tell window 1
    			set newTab to make new tab with properties {URL:myURL}
    		end tell
    		set active tab index of window 1 to activeIndex
    end tell

     

    —Michael

  2. Howdy Fellow Alfred-itors!

     

    I've been trying to figure out how I could modify Alfred's awesome keyword / search engine feature to enable me to do a Google search in a new background tab—i.e., *without* automatically shifting from my current browser tab (or current application) to the new browser tab where the search opens, as Alfred does by default.  There were a few forum posts over the years from users seeking this feature—but none of them was satisfactorily answered… Ha, but since I managed to figure out a workaround riiiiiight before I was about to give up, I thought I'd pay it forward and post it here —> since perhaps there are other users who'd like to enable to this search-in-background feature.

     

    This workflow enables you to (1) search Google using Alfred while browsing in Safari in a new background tab—as well as (2) to stay in a different (i.e., non-Safari) app and run the Google search entirely in the background… which can be helpful if you're, say, poring over an Excel spreadsheet and you want to remember to Google search something later—but don't want your focus to get yanked away from your current work.

     

    It's a simple two-step workflow design:

     

    1101740476_Screenshot2018-08-1915_38_03.png.ffd0d095cff66956236ecbc1b7b0b8b3.png 

     

    INPUTS = "Keyword" —> ACTIONS = "Run Script"

     

    NOTE:  You must select "/usr/bin/osacript (AS)" from the "Language" drop-down menu on the script action—and then select "with input as {query}" from the adjacent drop-down.

     

    Here is the Applescript to enter into the "Script" box:

    set myURL to "https://www.google.com/search?q={query}"
    
    tell application "Safari"
    	tell front window
    		make new tab at end of tabs with properties {URL:myURL}
    	end tell
    end tell

     

     

    And finally, here are screen-grabs of how I configured both workflow items:

     

    943002854_Screenshot2018-08-1916_02_05.png.f64603bf88d153703dc52ad06cbf7935.png

     

    1544641214_Screenshot2018-08-1915_38_27.png.14076d05f06b43de5686769a8113d395.png  

     

     

    I hope someone out there finds this helpful!

     

    Cheers,

     

    —Michael

×
×
  • Create New...