简体   繁体   English

Windows Phone C#如何捕捉全局钩子

[英]Windows Phone c# how to catch global hook

I have simple app: 我有一个简单的应用程序:

public MainPage()
{
    InitializeComponent();
    CameraButtons.ShutterKeyPressed += OnButtonFullPress;           
}
private void OnButtonFullPress(object sender, EventArgs e)
{
    //camera button pressed
}

When my app is active, all is great, but, when my app is not active, i cant catch, when camera button were pressed. 当我的应用程序处于活动状态时,一切都很好,但是,当我的应用程序处于非活动状态时,按下相机按钮时我无法捕捉。

Is this possible with default SDK? 默认的SDK是否可以?

There is a way to set your application as a default camera app on windows phone 8, but this feature is only available for 'special' developers like Microsoft, Nokia or other hardware companies. 有一种方法可以将您的应用程序设置为Windows Phone 8上的默认相机应用程序,但是此功能仅适用于“特殊”开发人员,例如Microsoft,诺基亚或其他硬件公司。 So it's not possible for you, most probably. 因此,对于您来说,这是最不可能的。

http://forums.windowscentral.com/windows-phone-8/234751-changing-default-camera-app.html http://forums.windowscentral.com/windows-phone-8/234751-changing-default-camera-app.html

Also if you look at the application lifecycle you'll see that after user minimizes your app it might be tombstoned and even unloaded from the memory. 同样,如果您查看应用程序生命周期,则会发现在用户最小化您的应用程序之后,该应用程序可能已被删除,甚至从内存中卸载。 So, you loose the control over the device resources. 因此,您可以放松对设备资源的控制。 That means that you can't get any events except the awake event. 这意味着除唤醒事件外,您无法获得任何其他事件。

The third option you have is to run the app under the lock screen, but it doesn't fit you as well. 您拥有的第三个选项是在锁定屏幕下运行该应用程序,但它也不适合您。 There is a limited set of api's you can use in this mode. 您可以在此模式下使用的api数量有限。 (Location and Audio). (位置和音频)。

So I'm sorry, but you can't do anything so far. 因此,很抱歉,您到目前为止无法做任何事情。

Unfortunately, this is not possible for third-party developers. 不幸的是,这对于第三方开发人员是不可能的。 You can only access the hardware buttons while your applications is running. 您只能在应用程序运行时访问硬件按钮。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM