public static extern bool GetWindowInfo(IntPtr hwnd, ref WINDOWINFO pwi);
public static AWindow GetAWINDOW(IntPtr hWnd) { /* * AWINDOW awin = windowList.FirstOrDefault(wind => wind.hwnd == hWnd); * * Guid guid; * * if (awin != null && awin.GUID != null) * { * guid = awin.GUID; * } * else * { * guid = Guid.NewGuid(); * } */ Guid guid = Guid.NewGuid(); AWindow theWINDOW = new AWindow { GUID = guid, Hwnd = hWnd, Title = GetTitleOfWindow(hWnd), ClassName = GetClassNameOfWindow(hWnd), BaseClassName = GetBaseClassNameOfWindow(hWnd), SavedParent = GetParent(hWnd), SavedStyle = GetWindowStyle(hWnd), SavedStyleEx = GetWindowStyleEx(hWnd), AutomationElement = GetAutomationElementOfWindow(hWnd), SavedRECT = SaveWindowRect(hWnd), NiceRECT = SaveNiceWindowRect(hWnd), BorderRECT = new RECT(), MinRECT = new RECT(), Icon = GetAppIcon(hWnd) }; theWINDOW.BorderRECT = GetWindowBorder(hWnd); theWINDOW.Placement = new WINDOWPLACEMENT(true); WINDOWPLACEMENT place = new WINDOWPLACEMENT(true); GetWindowPlacement(hWnd, ref place); theWINDOW.Placement = place; theWINDOW.LastPlacement = place; theWINDOW.IconImage = ToImageSource(theWINDOW.Icon); WINDOWINFO info = new WINDOWINFO(); info.cbSize = (uint)Marshal.SizeOf(info); bool gotInfo = GetWindowInfo(hWnd, ref info); theWINDOW.Info = info; uint threadId; GetWindowThreadProcessId(hWnd, out threadId); theWINDOW.ThreadProcessId = threadId; GUITHREADINFO guiInfo = GetWindowGUIThreadInfo(hWnd); theWINDOW.GuiThreadInfo = guiInfo; WindowStyles styles = new WindowStyles(); theWINDOW.WindowStyles = styles.FromHWND(hWnd); return(theWINDOW); }