Я "украл" код из http://improve.dk/archive/2007/04/07/finding-specific-windows.aspx
, но вместо того, чтобы записывать имя класса, заголовок и дескриптор в консоль, я хочу проверить, видна ли определенная кнопка.и если кнопка видна, я хочу развернуть окно.
я изменил эту часть =>
private static bool foundWindow(int handle)
{
bool buttonCheck = false;
IntPtr hButton = FindWindowEx((IntPtr)handle, IntPtr.Zero, "AfxWnd90u21", null);
if (hButton != IntPtr.Zero)
{
buttonCheck = true;
}
if (buttonCheck)
{
ShowWindowAsync(handle, (int)3); // maximize the window
}
return true;
}
the button class is `AfxWnd90u` and the instance is `21`. I wrote this in autoit before and AfxWnd90u21 is 100 % correct.
the problem is that i cant find the button with AfxWnd90u21. if i only use
IntPtr hButton = FindWindowEx((IntPtr)handle, IntPtr.Zero, "AfxWnd90u", null);
all windows get maximized.
It has to be something with the instance.
i hope you can help me,
thanks
Самое новое редактирование Я просто попытался найти имя классас "GetClassName".Я нахожу 190 ~ классов на ручку, но нужного мне класса там нет.я действительно в отчаянии, я надеюсь, что кто-то может мне помочь, спасибо
private static bool foundWindow(int handle)
{
int i = 0;
IntPtr hWnd = (IntPtr)handle;
// System.Windows.Forms.Control control = System.Windows.Forms.Control.FromHandle(hWnd);
StringBuilder sbClass = new StringBuilder(256);
while (hWnd != IntPtr.Zero)
{
++i;
///////////////////////////////////////////////////
////////////// Compare if the classname exists/////
GetClassName((int)hWnd, sbClass, sbClass.Capacity);
if (sbClass.ToString().Equals("AfxWnd90u21"))
{
MessageBox.Show(sbClass.ToString());
}
///////////////////////////////////////////////////
////// trying to find the correct class with findwindowEX//////////
IntPtr hButton = FindWindowEx(hWnd, IntPtr.Zero, "AfxWnd90u21", null);
if (hButton != IntPtr.Zero)
{
MessageBox.Show("true");
ShowWindowAsync(handle, (int)2); // maximize the window
}
hWnd = FindWindowEx(IntPtr.Zero, hWnd, null, null);
}
MessageBox.Show(""+i);
return true;
}