There is such a wonderful game World of Tanks, as in this game using the C # program, press the active button. Or rather how to send the enter button to this game so that what was actively pressed. I tried it like this, but it does not work:

// 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); // Send a series of key presses to the Calculator application. private void button1_Click(object sender, EventArgs e) { // Get a handle to the Calculator application. The window class // and window name were obtained using the Spy++ tool. IntPtr calculatorHandle = FindWindow(null,"WoT Client"); // Verify that Calculator is a running process. if (calculatorHandle == IntPtr.Zero) { MessageBox.Show("Calculator is not running."); return; } // Make Calculator the foreground application and send it // a set of calculations. SetForegroundWindow(calculatorHandle); SendKeys.Send("{ENTER}"); } 
  • And you can find out why to do all this? As far as I know, this is against the rules of the company and the game itself. Ban is around the corner) - Yurii Manziuk
  • @YuriiManziuk is right ... But as for the question, if you press ENTER in the game itself, does it work? - MaximK
  • You won't get a ban for it if you press everything from the keyboard and the program doesn't work with the code above - Valya Blond
  • This code finds and makes active the client window. And sends Enter there. But what exactly is currently active in this window? Probably, you need to find the desired button and make it active. Try the Spy ++ utility to find the item you want. - Alexander Petrov
  • one
    Well, if so, SendKeys is useless. And Spy ++ doesn't help. Idea: to solder a robot on Arduin, which will carry the mouse around the table, to fasten pattern recognition from a video camera looking at the monitor ... - Alexander Petrov

0