gpt4 book ai didi

windows-phone-8 - Microsoft.Smartdevice.Connectivity 和 Windows Phone 8,启动 native 应用程序,发送输入?

转载 作者:行者123 更新时间:2023-12-04 12:54:26 25 4
gpt4 key购买 nike

我编写了一个小的 .NET 控制台程序来启动 Windows 8 模拟器。非常直接:

using Microsoft.SmartDevice.Connectivity;
using Microsoft.SmartDevice.Connectivity.Interface;
using Microsoft.SmartDevice.MultiTargeting.Connectivity;

MultiTargetingConnectivity connectivity = new MultiTargetingConnectivity(CultureInfo.CurrentUICulture.LCID);
var devices = connectivity.GetConnectableDevices();
ConnectableDevice connectableDevice = devices[2];
Console.WriteLine("Found Connectable Device \'" + connectableDevice.Name + "\' for Device id {" + connectableDevice.Id + "}.");

很简单。但是,我现在想做的是以编程方式与设备交互。我知道我可以使用 iDevice.installApplication 启动我自己的应用程序,但我真正想做的是运行模拟器附带的内置应用程序(邮件应用程序)。我可以使用 SmartDevice.Connectivity libs 发送触摸,或启动“隐藏”应用程序,这些应用程序未出现在 GetInstalledApplications() 中方法? API 很少,而且似乎没有大量开发人员在使用它。

最佳答案

我实际上找到了比 SmartDevice 更好的框架框架。内C:\Program Files (x86)\Microsoft XDE\8.0您可以在文件夹中找到 Microsoft.XDE DLL 有助于为 Windows 8 模拟器包装器/皮肤提供动力,并且是允许您与模拟器交互的托管库。示例代码:

private static void BootViaXdeLibs()
{
var factory = new Microsoft.Xde.Wmi.XdeWmiFactory();
Console.WriteLine("Polling for virtual machines");

var virtualMachine = factory.GetAllXdeVirtualMachines(SettingsOptions.None)[2];
Console.WriteLine("Found machine {0}", virtualMachine.Name);

if (virtualMachine.EnabledState != VirtualMachineEnabledState.Disabled)
{
Console.WriteLine("Virtual Machine {0} is already running. Shutting down. ", virtualMachine.Name);
virtualMachine.Stop();
while (virtualMachine.EnabledState != VirtualMachineEnabledState.Disabled)
{
Thread.Sleep(1000);
}
}

Console.WriteLine("Starting {0}", virtualMachine.Name);

virtualMachine.Start();
while (virtualMachine.EnabledState == VirtualMachineEnabledState.Starting)
{
Thread.Sleep(1000);
}

Console.WriteLine("Sleeping before image capture to give boot time");
Thread.Sleep(30000);

//Click on the screen
virtualMachine.SendMouseEvent(new MouseEventArgs(MouseButtons.Left, 1, 295, 260, 0));
Thread.Sleep(100);
virtualMachine.SendMouseEvent(new MouseEventArgs(MouseButtons.None, 0, 295, 260, 0));
Thread.Sleep(1000);

Console.WriteLine("Saving screenshot");

//Capture Screen
var res = virtualMachine.GetCurrentResolution();
var image = virtualMachine.GetScreenShot(0, 0, res.Width, res.Height);
image.Save("C:\\image.png", ImageFormat.Png);

virtualMachine.Stop();
}

关于windows-phone-8 - Microsoft.Smartdevice.Connectivity 和 Windows Phone 8,启动 native 应用程序,发送输入?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19569770/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com