private IntPtr GetWindowChildDFSByDepth(IntPtr window, int index) { IntPtr child = window; for (int i = 0; i < index; i++) { child = win32API.FindWindowEx(child, IntPtr.Zero, null, null); if (child == IntPtr.Zero) { return child; } } return child; }