Houdah Software Forum Archive

Alfred Workflow

Member #1175
I've been using an Alfred workflow calling the AppleScript:

tell application id "com.houdah.HoudahSpot4"
    search "{query}"
    activate
end tell

My results are too general, and I'd like to have the search term entered into the first field under the "Refine" section after: Name...contains... XXX.

Can someone help me update the script?

Thanks,

 

Houdah Software
Hi Larry,

Try the following script:

tell application id "com.houdah.HoudahSpot4"
        search "search:name {query}"
        activate
end tell

 
When you enter "Apple Tree" as query through Alfred, HoudahSpot will search for files whose names have both the word prefixes "Apple" and "Tree". This will find a file named "Treecutter Applejuice".

Add quotes if you want HoudahSpot to treat the query as single prefix:

tell application id "com.houdah.HoudahSpot4"
        search "search:name \"{query}\""
        activate
end tell
Now a search for "Tree" will find the "Treecutter Applejuice" file. A search for "Apple" will not.

Add asterisk wildcards to search for names that contain the query:

tell application id "com.houdah.HoudahSpot4"
        search "search:name \"*{query}*\""
        activate
end tell

Now searches for "Apple", "Tree", or "Cutter" will all find the "Treecutter Applejuice" file.

The big advantage of the first script is that it leaves all option open. Type Apple Tree without the quotes in Alfred to search by both word prefixes. Type "Apple Tree" with the quotes to search for the combined prefix. Type asterisk wildcards where you need them.

Best,
Pierre Bernard

Member #1175 original poster
Is there a way of calling the Apple Mail Messages template through AppleScript?

Thanks,
Houdah Software

tell applicationid "com.houdah.HoudahSpot4"

set homeFolderPath to POSIX path of (path tohome folder)

set templatePath to homeFolderPath & "Library/Application Support/com.houdah.HoudahSpot4/Templates/Sample Templates/Apple Mail Messages.hstemplate"

search "search:name {query}" templatetemplatePath

activate

end tell