0
我有一個遙控器,在應用中的鍵盤作品和播放/暫停在PC/TVWindows媒體按鈕不工作在WPF
CTRL + P指向。
遠程控制可以在媒體播放器中播放/暫停,但它不適用於WPF應用程序。
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));
}
我的XAML是
<Window.CommandBindings>
<CommandBinding 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>
事件倒帶的工作和快進,而不是播放/暫停和停止。
我嘗試下載媒體玻璃http://mediaglass.codeplex.com/並且這在遙控器上按CTRL + P
當同樣的問題我已經發現,通過應用以下
System.Windows.Input.Key wpfLeftKey = Key.LeftCtrl;
var formsKey = (Forms.Keys)KeyInterop.VirtualKeyFromKey(wpfLeftKey);
我得到不同的結果,我輸出
Windows 32 = LControlKey
WPF = LeftControl
我的想法是要在遙控編程送出LControlKey
因此,我需要做的是在Win32應用程序記錄LControlKey並強制事件觸發時引發一個事件。有什麼建議麼。 (後InitiliseComponent()?
我可以completey這裏因循守舊的,或者可能是正確的???。
伊夫添加 InputBinding> Window。 InputBindings>,我得到的錯誤'找不到'System.Windows.Input.InputBinding'類型的匹配構造函數,你可以使用Arguments或FactoryMethod指令構造這種類型'行號'14'和行位置'10'。 –
我添加了 它做同樣的事情:( –
它工作時,我添加媒體密鑰綁定MyPlayPause.InputGestures.Add(新的KeyGesture(Key.MediaPlayPause));因爲遙控器正在發送不同的命令 –