Kaydol:
Kayıt Yorumları
(
Atom
)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Diagnostics;
namespace C_Sharp_Process_Notepad_Kontrol_Etme
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
[DllImport("user32.dll")]
private static extern bool SetForegroundWindow(IntPtr hWnd);
private void button1_Click(object sender, EventArgs e)
{
Process[] process = System.Diagnostics.Process.GetProcessesByName("notepad");
if (process.Length > 0)
{
//Aynı process birden fazla çalışıyor olabilir. Hepsini kontrol et
for (int i = 0; i < process.Length; i++)
{
if (process[i].MainWindowTitle.Substring(0, 1) == "a")
{
SetForegroundWindow(process[i].MainWindowHandle);
process[i].WaitForInputIdle();
SendKeys.Send(textBox1.Text);
}
}
}
}
private void button2_Click(object sender, EventArgs e)
{
Process[] process = System.Diagnostics.Process.GetProcessesByName("notepad");
if (process.Length > 0)
{
//Aynı process birden fazla çalışıyor olabilir. Hepsini kontrol et
for (int i = 0; i < process.Length; i++)
{
if (process[i].MainWindowTitle.Substring(0, 1) == "b")
{
SetForegroundWindow(process[i].MainWindowHandle);
process[i].WaitForInputIdle();
SendKeys.Send(textBox2.Text);
}
}
}
}
}
}
Hiç yorum yok :
Yorum Gönder