Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/304.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何从带有短语主题的Cortana命令中提取参数,通过文本激活? 高级:_C#_Win Universal App_Cortana - Fatal编程技术网

C# 如何从带有短语主题的Cortana命令中提取参数,通过文本激活? 高级:

C# 如何从带有短语主题的Cortana命令中提取参数,通过文本激活? 高级:,c#,win-universal-app,cortana,C#,Win Universal App,Cortana,我想在文本模式下使用自定义Cortana命令“记事本”。例如,按WIN+S并键入“appname记事本示例语句!”。 (这将打开记事本并输入“示例语句!”) 记事本命令已在语音模式下运行:当我按WIN+C并说“appname记事本示例句子!”时,我的记事本脚本将与有效负载“示例句子!”一起运行 问题是: 当我按WIN+S并输入“appname记事本示例句子!”时,SpeechRecognitionResult的文本属性是“记事本…”(与语音相反,它是“记事本示例句子!”) 代码: VCD.x

我想在文本模式下使用自定义Cortana命令“记事本”。例如,按WIN+S并键入“appname记事本示例语句!”。
(这将打开记事本并输入“示例语句!”)

记事本命令已在语音模式下运行:当我按WIN+C并说“appname记事本示例句子!”时,我的记事本脚本将与有效负载“示例句子!”一起运行

问题是: 当我按WIN+S并输入“appname记事本示例句子!”时,SpeechRecognitionResult的文本属性是“记事本…”(与语音相反,它是“记事本示例句子!”)

代码: VCD.xml摘录 问题重述
如何更改上述代码以在文本模式下提取命令参数(即除应用程序名和命令名以外的所有参数)?

从这里找到了答案:。不知道该拿赏金怎么办。。。
case CortanaCommand.Notepad:
       argument = speechRecognitionResult.SemanticInterpretation.Properties["wildcardArgs"].FirstOrDefault();
       // the magic line ^
       processedCommand = new NotepadCortanaCommand(argument, diagnostics);
       break;
public static CortanaCommand ProcessCommand(SpeechRecognitionResult speechRecognitionResult, CommandDiagnostics diagnostics)
{
    // Get the name of the voice command and the raw text
    string voiceCommandName = speechRecognitionResult.RulePath[0];
    string text = speechRecognitionResult.Text;
    string mode = speechRecognitionResult.SemanticInterpretation.Properties[interpretationKey].FirstOrDefault();
    // When mode is voice, text is "Notepad Example sentence!"
    // When mode is text, text is "Notepad ..."
      // How can one retrieve "Example sentence!" from "..." !?
      // Is there some property other than speechRecognitionResult.Text that holds the raw text typed? 

    string argument = null;
    CortanaCommand processedCommand = null;

    switch (voiceCommandName)
    {
       // ...
       case CortanaCommand.Notepad:
           const string notepad = "Notepad";
           argument = CortanaCommand.StripOffCommandName(notepad, text);
           processedCommand = new NotepadCortanaCommand(argument, diagnostics);
           break;

        default:
                Debug.WriteLine("Command Name Not Found:  " + voiceCommandName);
            break;
    }
    return processedCommand;
}
case CortanaCommand.Notepad:
       argument = speechRecognitionResult.SemanticInterpretation.Properties["wildcardArgs"].FirstOrDefault();
       // the magic line ^
       processedCommand = new NotepadCortanaCommand(argument, diagnostics);
       break;