Trigger volume buttons to take picture UWP

前端 未结 2 1886
暖寄归人
暖寄归人 2020-12-20 05:20

I try to use a selfie stick, but as windows 10 camera app does not provide the possibility to take picture and record video with it, I was wondering if there is a possibilit

2条回答
  •  心在旅途
    2020-12-20 06:03

    There is a solution. When I tested what hardware button do, it fired CoreWindow_KeyDown with VirtualKey of 174(volume down) and 175(up).

    //in ctor
    Window.Current.CoreWindow.KeyDown += CoreWindow_KeyDown;
    //
    
    void CoreWindow_KeyDown(Windows.UI.Core.CoreWindow sender, Windows.UI.Core.KeyEventArgs args)
    {
        if ((int)args.VirtualKey == 175 || (int)args.VirtualKey == 174))
        {
         //take a picture
        }
    }
    

提交回复
热议问题