嘿,我使用C#,试图键命令发送到Windows Media Center的Windows 7中使用keySend的Windows Media Center
目前,我公司可以派键,如4和看到的数字上的Windows Media 4次出现中央。
问题是像Ctrl + p(暂停电影)的任何组合键似乎对媒体中心没有任何影响。
任何帮助将不胜感激。这是我的代码片段。
// Get a handle to an application window.
[DllImport("USER32.DLL", CharSet = CharSet.Unicode)]
public static extern IntPtr FindWindow(string lpClassName,
string lpWindowName);
// Activate an application window.
[DllImport("USER32.DLL")]
public static extern bool SetForegroundWindow(IntPtr hWnd);
String HandleClass = "eHome Render Window";
String HandleWindow = "Windows Media Center";
private bool SendKeyCommand()
{
bool success = true;
IntPtr PrgHandle = FindWindow(HandleClass, HandleWindow);
if (PrgHandle == IntPtr.Zero)
{
MessageBox.Show(HandleWindow + " is not running");
return false;
}
SetForegroundWindow(PrgHandle);
SendKeys.SendWait("^p");
return success;
}
我知道这是无关紧要的,但我已经注意到了的extern方法,它代表着什么。 – Tarik 2010-09-25 06:14:51
extern修饰符表示该方法在C#代码之外实现。 http://msdn.microsoft.com/en-us/library/e59b22c5%28VS.80%29.aspx – Scott 2010-09-25 19:17:00