Merhaba, yapmak istediğim şey mesela F7 tuşuna basıp oyuna geçip F7 bastığımda oyunla formumun bağlantısını kurmak istiyorum umarım anlatabilmişimdir.
C# ile yapılan bir örneğinide şöyle bırakayım.
[CODE title="C#"]using System.Runtime.InteropServices;
[DllImport ("User32.dll")]
static extern int SetForegroundWindow(IntPtr point);
Process p = Process.GetProcessesByName("notepad").FirstOrDefault();
if (p != null)
{
IntPtr h = p.MainWindowHandle;
SetForegroundWindow(h);
SendKeys.SendWait("Kod Evreni");
}
else
{
Process islem = Process.Start("notepad.exe");
islem.WaitForInputIdle();
IntPtr h = islem.MainWindowHandle;
SetForegroundWindow(h);
SendKeys.SendWait("Kod Evreni");
}[/CODE]
C# ile yapılan bir örneğinide şöyle bırakayım.
[CODE title="C#"]using System.Runtime.InteropServices;
[DllImport ("User32.dll")]
static extern int SetForegroundWindow(IntPtr point);
Process p = Process.GetProcessesByName("notepad").FirstOrDefault();
if (p != null)
{
IntPtr h = p.MainWindowHandle;
SetForegroundWindow(h);
SendKeys.SendWait("Kod Evreni");
}
else
{
Process islem = Process.Start("notepad.exe");
islem.WaitForInputIdle();
IntPtr h = islem.MainWindowHandle;
SetForegroundWindow(h);
SendKeys.SendWait("Kod Evreni");
}[/CODE]