0
votes

When you say "Hi Cortana", Cortana listens for a command. For example: Take a picture, or shut down or else.

I want to do this programaticaly in UWP (C#) . Execute a command like "Take a picture" or "Shut down" in UWP. (It doesnt matter if the user is asked weather they want that action to be taken, that is, I am not trying to bypass security or do something evil that the user doesnt want. )

I dont want to create a new capability, but just use existing ones. Preferably using a text string. For example: I want to shut down the device. I want to replicate the process: "hey cortana" "Shut Down" "Yes" that the user says. I want to create a function that does this

void ExecuteCommand(String command) {......}

And if I call ExecuteCommand ("shut down"); The device shuts down

Is this possible? If so, how can I do this?

1
Are you looking to integrate your app with Cortana or do you need functionality similar to how Cortana works? In case of the latter I would recommend looking at the windows.media.speechrecognition namespaceLennart Stoop
The second would be better as i dont want cortana to appear. But I dont care about the speechrecognition part. I just want to activate the commands. For example: I want to shut down the device. I want to replicate the process: "hey cortana" "Shut Down" "Yes" that the user says. I want to create a function that does this void ExecuteCommand(String command) {......} And if I call ExecuteCommand ("shut down"); The device shuts downkkica
I dont want to get a command from the user. I just want to execute it.kkica
Afaik there is no API (yet) that makes it that easy. From my understanding of the speechrecognition API your app is to listen to spoken commands and ideally the UI is built around that to interact with the user in that mannerLennart Stoop

1 Answers

0
votes

Yes, it is possible.

I understand you want to interact with a background app in Cortana like the following example shows: cortana-progress-screen

This is an example of a progress screen for an app called Adventure Works. In this example, a user has canceled a trip to Las Vegas. The progress screen includes a message customized for the action, an icon, and a content tile with information about the trip being canceled.

In order to do so, you'll have to use the following APIs:

You can get started by using the Cortana voice command sample of the Adventure Works app from here that is related to the following documentations: