private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll")]
private static extern bool SetForegroundWindow(IntPtr hWnd);
public static void Test()
{
IntPtr zero = IntPtr.Zero;
for (int i = 0; (i < 60) && (zero == IntPtr.Zero); i++)
{
zero = FindWindow(null, "Minecraft 1.8.8");
}
if (zero != IntPtr.Zero)
{
SetForegroundWindow(zero);
SendKeys.Send("D");
SendKeys.Send("D");
SendKeys.Send("D");
SendKeys.Send("D");
SendKeys.Send("D");
SendKeys.Send("D");
SendKeys.Send("D");
SendKeys.Send("D");
SendKeys.Send("D");
SendKeys.Send("D");
SendKeys.Send("D");
}
}