OmniFocus Collection Alfred workflow - turn speech off

I started using the OmniFocus Collection Alfred workflow the other day. It seems great, but the one thing that’s stopping me using it is that when I search for a particular project, it will speak the results of the search out loud. Is there a way to turn that off?

1 Like

Ah, looking through the documentation, I believe you are referencing the project search command speaks :

${matchCount} ${projectOrProjects} matched.

Documentation: Omni Automation and Alfred

This page details the steps required to create the Alfred action. You could replace the embedded script with this version with the spoken response omitted, which becomes:

(async (arg) => {
	try {
		matchedProjects = projectsMatching(arg)

		if(matchedProjects.length === 0){
			messageStr = `No projects were found matching: ${arg}`
			throw {
				name: "Empty Search",
				message: messageStr
			}
		}
		
		matchCount = matchedProjects.length
		
		itemsArray = new Array()
		for (i = 0; i < matchedProjects.length; i++){ 
			aProject = matchedProjects[i]

			switch(aProject.status) {
				case Project.Status.Active:
					var projectStatus = "Active"
					break; 
				case Project.Status.Done:
					var projectStatus = "Done"
					break;
				case Project.Status.Dropped:
					var projectStatus = "Dropped"
				default:
					var projectStatus = "OnHold"
			}

			itemObj = new Object()
			itemObj.title = aProject.name
			itemObj.subtitle = `Status: ${projectStatus}`
			itemObj.arg = aProject.id.primaryKey
			itemsArray.push(itemObj)
		}
		jsonObj = new Object()
		jsonObj.items = itemsArray
		jsonStr = JSON.stringify(jsonObj)
		
		encodedJSON = encodeURIComponent(jsonStr)
		alfredWorkflowID = "com.omni-automation.of.alfred-collection"
		alfredTriggerID = "displayResults"
		urlStr = `alfred://runtrigger/${alfredWorkflowID}/${alfredTriggerID}/?argument=${encodedJSON}`
		URL.fromString(urlStr).open()	
	}
	catch(err){
		new Alert(err.name, err.message).show()
	}
})(argument);

Encoded, the script would be this:

omnifocus://localhost/omnijs-run?script=%28async%20%28arg%29%20%3D%3E%20%7B%0A%09try%20%7B%0A%09%09matchedProjects%20%3D%20projectsMatching%28arg%29%0A%0A%09%09if%28matchedProjects%2Elength%20%3D%3D%3D%200%29%7B%0A%09%09%09messageStr%20%3D%20%60No%20projects%20were%20found%20matching%3A%20%24%7Barg%7D%60%0A%09%09%09throw%20%7B%0A%09%09%09%09name%3A%20%22Empty%20Search%22%2C%0A%09%09%09%09message%3A%20messageStr%0A%09%09%09%7D%0A%09%09%7D%0A%09%09%0A%09%09matchCount%20%3D%20matchedProjects%2Elength%0A%09%09%0A%09%09itemsArray%20%3D%20new%20Array%28%29%0A%09%09for%20%28i%20%3D%200%3B%20i%20%3C%20matchedProjects%2Elength%3B%20i%2B%2B%29%7B%20%0A%09%09%09aProject%20%3D%20matchedProjects%5Bi%5D%0A%0A%09%09%09switch%28aProject%2Estatus%29%20%7B%0A%09%09%09%09case%20Project%2EStatus%2EActive%3A%0A%09%09%09%09%09var%20projectStatus%20%3D%20%22Active%22%0A%09%09%09%09%09break%3B%20%0A%09%09%09%09case%20Project%2EStatus%2EDone%3A%0A%09%09%09%09%09var%20projectStatus%20%3D%20%22Done%22%0A%09%09%09%09%09break%3B%0A%09%09%09%09case%20Project%2EStatus%2EDropped%3A%0A%09%09%09%09%09var%20projectStatus%20%3D%20%22Dropped%22%0A%09%09%09%09default%3A%0A%09%09%09%09%09var%20projectStatus%20%3D%20%22OnHold%22%0A%09%09%09%7D%0A%0A%09%09%09itemObj%20%3D%20new%20Object%28%29%0A%09%09%09itemObj%2Etitle%20%3D%20aProject%2Ename%0A%09%09%09itemObj%2Esubtitle%20%3D%20%60Status%3A%20%24%7BprojectStatus%7D%60%0A%09%09%09itemObj%2Earg%20%3D%20aProject%2Eid%2EprimaryKey%0A%09%09%09itemsArray%2Epush%28itemObj%29%0A%09%09%7D%0A%09%09jsonObj%20%3D%20new%20Object%28%29%0A%09%09jsonObj%2Eitems%20%3D%20itemsArray%0A%09%09jsonStr%20%3D%20JSON%2Estringify%28jsonObj%29%0A%09%09%0A%09%09encodedJSON%20%3D%20encodeURIComponent%28jsonStr%29%0A%09%09alfredWorkflowID%20%3D%20%22com%2Eomni%2Dautomation%2Eof%2Ealfred%2Dcollection%22%0A%09%09alfredTriggerID%20%3D%20%22displayResults%22%0A%09%09urlStr%20%3D%20%60alfred%3A%2F%2Fruntrigger%2F%24%7BalfredWorkflowID%7D%2F%24%7BalfredTriggerID%7D%2F%3Fargument%3D%24%7BencodedJSON%7D%60%0A%09%09URL%2EfromString%28urlStr%29%2Eopen%28%29%09%0A%09%7D%0A%09catch%28err%29%7B%0A%09%09new%20Alert%28err%2Ename%2C%20err%2Emessage%29%2Eshow%28%29%0A%09%7D%0A%7D%29%28argument%29%3B
1 Like

@Sal I wonder if it’s general knowledge that you can pass/call a script that way, I only heard about it when you were on the Automators podcast. Thanks for your work over on the omni-automation site, great job! FYI for this forum, encode scripts here: Omni Automation Script URL Constructor.

LOL! There’s so much to Omni Automation that it’s difficult to highlight it all!

Here’s the section on Script URLs that details all aspects of creating Omni Automation Script URLs and provides tools for their creation.

Thank you for your interest in automation and OmniFocus. With the introduction of Apple Vision Pro, the story expands even more. More automation goodness!

Cheers — SAL

1 Like