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
|
int z = 0;
int id;
//je recupere le handle du bureau
IntPtr hwnd = GetWindow(GetDesktopWindow(), GetWindow_Cmd.GW_CHILD);
while (hwnd != null && hwnd != IntPtr.Zero)
{
//sur chaque handle de mes processus lancés je get l'id...
GetWindowThreadProcessId(hwnd, out id);
// Et enfin a partir de l'ID je recupere le nom du process
string nameProcess = Process.GetProcessById(id).ProcessName;
//ce nom de processus je verifie s'il est bien dans mon dictionnaire.
Color c;
dictionnaryProcess.TryGetValue("System.Diagnostics.Process (" + nameProcess + ")", out c);
if (IsWindowVisible(hwnd))
{
RECT ProcRect;
GetWindowRect(hwnd, out ProcRect);
int H = (ProcRect.Bottom - ProcRect.Top) / coeff;
int W = (ProcRect.Right - ProcRect.Left) / coeff;
int left = ProcRect.Left / coeff;
int top = ProcRect.Top / coeff;
//je dessine mon canvas
can.Children.Add(drawRectangle(W, H, top, left, c));
z++;
}
hwnd = GetWindow(hwnd, GetWindow_Cmd.GW_HWNDNEXT); |
Partager