【发布时间】:2015-10-08 14:01:13
【问题描述】:
有没有办法使用 VoiceCommand 方法以编程方式触发 Cortana,就好像 Cortana 已注册“Hey Cortana”开始收听一样?
【问题讨论】:
-
您的目标是什么平台? Windows Phone 8.1 还是 UWP?
标签: windows-phone cortana
有没有办法使用 VoiceCommand 方法以编程方式触发 Cortana,就好像 Cortana 已注册“Hey Cortana”开始收听一样?
【问题讨论】:
标签: windows-phone cortana
我也有同样的问题,但对于 Windows 10。找到了解决方案:在 Windows 10 上,您可以使用Win + C 击键组合触发 Cortana。要以编程方式使其工作,您需要与 Win32 SendInput 方法进行互操作。幸运的是,有一个 NuGet 包 Windows Input Simulator,它就是这样做的:
Install-Package InputSimulator
安装后,我可以使用以下方式从 WPF 应用程序触发 Cortana:
var sim = new InputSimulator();
sim.Keyboard.ModifiedKeyStroke(VirtualKeyCode.LWIN, VirtualKeyCode.VK_C);
【讨论】:
你不可能得到最接近的方法是使用这样的东西:
async static void LaunchCortana(bool untrusted, string searchText)
{
// The URI to launch
string uriToLaunch = @"http://www.bing.com/";
searchText = "search?q=" + searchText.Replace(" ", "+");
var uri = new Uri(uriToLaunch + searchText);
// Set the option to show a warning
var options = new Windows.System.LauncherOptions();
options.TreatAsUntrusted = untrusted;
// Launch the URI with a warning prompt
var success = await Windows.System.Launcher.LaunchUriAsync(uri, options);
if (success)
{
// URI launched
}
else
{
// URI launch failed
}
}
或
await Launcher.LaunchUriAsync(new Uri("bing://home"));
它只适用于Windows Phone 8.x,并利用 Cortana 禁用 Bing.com 的事实,但您不能使用它来启动 Cortana 命令。将开始网络搜索。
【讨论】: