Hey, I am using C# to try to send key commands to windows media center in windows 7.
Currently I can send keys like 4 and see the number 4 appears on the windows media center.
The problem is any key combination like Ctrl+p (to pause a movie) does not seem to have any effects on the media center.
Any help would be greatly appreciated. Here is my code snippet.
// 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;
}