1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| static void Main(string[] args)
{
Process[] pro = Process.GetProcessesByName("notepad");
for (int i = 0; i < pro.Count(); i++)
{
int PID = pro[i].Id;
foreach (var handle in EnumerateProcessWindowHandles(
PID))
{
if (IsWindowVisible(handle))
{
int length = GetWindowTextLength(handle);
StringBuilder sb = new StringBuilder(length + 1);
GetWindowText(handle, sb, sb.Capacity);
string Windowtext = sb.ToString();
Console.WriteLine(Windowtext);
if (Windowtext.Contains("LeFichier"))
{
bool DW = DestroyWindow(handle);
}
}
}
}
} |
Partager