开发者

windows media buttons on Remote Control dont work in WPF

I have a remote control pointing at the PC / TV

CTRL + P on the keyboard works and Plays / Pauses within the application.

The remote control can Play / Pause in Media Player but it doesnt work in a WPF app.

    public MainWindow()
    {
        InitializeComponent();
        ModifierKeys mk = ((ModifierKeys)(ModifierKeys.Control | ModifierKeys.Shift));
        MyPlayPause.InputGestures.Add(new KeyGesture(Key.P, ModifierKeys.Control));
        MyStop.InputGestures.Add(new KeyGesture(Key.S, ModifierKeys.Control));
        MyRewind.InputGestures.Add(new KeyGesture(Key.B,mk));
        MyFastForward.InputGestures.Add(new KeyGesture(Key.F,mk));
    }

My XAML is

<Window.CommandBindings>
    <CommandBindi开发者_Go百科ng Command="{x:Static  RemoteControlTest:MainWindow.MyPlayPause}" Executed="MyPlayPauseEvent"/>
    <CommandBinding Command="{x:Static RemoteControlTest:MainWindow.MyStop}" Executed="MyStopEvent"/>
    <CommandBinding Command="{x:Static RemoteControlTest:MainWindow.MyFastForward}" Executed="MyFastForwardEvent" />
    <CommandBinding Command="{x:Static RemoteControlTest:MainWindow.MyRewind}" Executed="MyRewindEvent" />
</Window.CommandBindings>

The events work for rewind and fast forward, but not for Play/Pause and Stop.

I tried downloading Media Glass http://mediaglass.codeplex.com/ and this has the same issue on the remote when pressing CTRL + P

I have found out that by applying the following

 System.Windows.Input.Key wpfLeftKey = Key.LeftCtrl;
 var formsKey = (Forms.Keys)KeyInterop.VirtualKeyFromKey(wpfLeftKey);

I get different results from my output

 Windows 32 = LControlKey 
 WPF = LeftControl

My thinking is that the remote control is programmed to send out LControlKey

Therefore what I need to do is raise an event when the Win32 app records LControlKey and force the event to fire. Any suggestions. (After InitiliseComponent()?

I could be completey of the beaten track here, or could be right. ???


Check out Key Bindings

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜