i wrote this programm
Code:
using System;
using System.Runtime.InteropServices;
using System.Drawing;
using System.Windows.Forms;
namespace SimulateKeyPress
{
class Form1 : Form
{
private Button button1 = new Button();
[STAThread]
public static void Main()
{
Application.EnableVisualStyles();
Application.Run(new Form1());
}
public Form1()
{
button1.Location = new Point(10, 10);
button1.TabIndex = 0;
button1.Text = "Click to Find co";
button1.AutoSize = true;
button1.Click += new EventHandler(button1_Click);
this.DoubleClick += new EventHandler(Form1_DoubleClick);
this.Controls.Add(button1);
}
// 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 co application.
private void button1_Click(object sender, EventArgs e)
{
IntPtr coHandle = FindWindow(null, "[Conquer Online]");
// Verify that co is a running process.
if (coHandle == IntPtr.Zero)
{
MessageBox.Show("CO is not running.");
return;
}
// Make co the foreground application and send it
// a set of calculations.
SetForegroundWindow(coHandle);
SendKeys.SendWait("^"+"s");
}
// Send a key to the button when the user double-clicks anywhere
// on the form.
private void Form1_DoubleClick(object sender, EventArgs e)
{
SendKeys.Send("{ENTER}");
}
}
}







