Bonjour à tous, je cherche à récupérer le handle d'une fenêtre autrement qu'avec la méthode GetForegroundWindow().
En fait ce qui me dérange c'est qu'à l'ouverture de mes fenêtres je suis obligé de faire une Thread.Sleep(1000) en choisissant 1000 de manière assez aléatoire pour être sur que la fenêtre soit ouverte. Mais imaginons que
IE soit assez lent à l'ouverture sur un autre PC, 1000 est clairement insuffisant donc je voudrais gérer ça d'une autre manière si c'est possible.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
 
String[] links = { linkurl, fburl, twurl, neturl };
 
int[] xs = { linkwidth, fbwidth, twwidth, netwidth };
int[] ys = { linkheight, fbheight, twheight, netheight };
int[] ws = { linkboxdim, fbboxdim, twboxdim, netboxdim };
int[] hs = { linkboxdim, fbboxdim, twboxdim, netboxdim };
 
int pos = 0;
 
foreach (String link in links)
{
     ProcessStartInfo psi = new ProcessStartInfo(browser, ieparameter + " " + link);
     processesList.Add(Process.Start(psi));
     Thread.Sleep(1000);
     IntPtr id = GetForegroundWindow();
     //MessageBox.Show("lien : " + link.ToString());
     MoveWindow(id,xs[pos],ys[pos],ws[pos],hs[pos],true);
     pos++;
}