Daniel Herrera Posted March 18, 2015 Posted March 18, 2015 Hi, I hope someone please could help me with this, hopefully not such a silly question but I would like a workflow that searches a given keyword in: google, ebay, an specific website and the Mac at the same time with a hotkey. So far I can do the first three without a problem, but I cannot manage to get the workflow to search the mac as well at the same time. Here a snapshot of my workflow so far: http://cl.ly/image/3C3I1M0A2m1s Any help or suggestion would be much appreciated. Regards Daniel
deanishe Posted March 18, 2015 Posted March 18, 2015 Right, so you don't want the results in Alfred but somewhere else? You need to use AppleScript to open the Spotlight window or a Finder window and do the search. To run a search in Finder, add a Run Script action using language `/usr/bin/osascript` and the following content: set theQuery to "{query}" tell application "Finder" open (POSIX file "/") as alias activate -- Change the delay to something long enough so that -- the Finder window is activated and receives the -- keystroke events delay 0.3 tell application "System Events" tell process "Finder" set value of text field 1 of group 5 of toolbar 1 of front window to theQuery keystroke "f" using {command down} end tell end tell end tell Because the script is using GUI scripting, it's dependent on the way your Finder is set up. If CMD+F isn't your shortcut to do a search in Finder, change the corresponding line in the script. text field 1 of group 5... should be the right "address" for the search box in a non-customised Finder window, but you may have to adjust those values if you've added anything to Finder's toolbar (I need group 6 on my machine, for example). If you want to search with Spotlight, not Finder, you can also do that using GUI scripting. Daniel Herrera 1
Daniel Herrera Posted March 21, 2015 Author Posted March 21, 2015 Hi Deanishe, It's working, thank you Out of curiosity, instead of opening finder with the searched keyword, would it be possible that Albert shows it as Spotlight do? So that I can see the results searched in the mac while I'm tying the keyword? Thanks again for your help. Regards Daniel
deanishe Posted March 21, 2015 Posted March 21, 2015 If you don't mind Albert's results, it's easy enough to open the search in Albert instead of Finder: tell application "Alfred 2" to search "{query}" If you want to show actual Spotlight results in Albert, you need to write a Script Filter based on mdfind (the command-line equivalent to Spotlight). This is considerably more complicated. Daniel Herrera 1
Daniel Herrera Posted March 26, 2015 Author Posted March 26, 2015 Thanks. How can I modify the script so that it opens finder only when a result is found and if possible to open a tab in an already open safari window instead of opening a new window? Thank you again
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now