예제 #1
0
        public static GUITHREADINFO GetWindowGUIThreadInfo(IntPtr hwnd)
        {
            uint processId;

            GetWindowThreadProcessId(hwnd, out processId);

            GUITHREADINFO guithreadinfo = new GUITHREADINFO(true);

            GetGUIThreadInfo(processId, out guithreadinfo);

            return(guithreadinfo);
        }
예제 #2
0
 public static extern bool GetGUIThreadInfo(uint idThread, out GUITHREADINFO pgui);
예제 #3
0
        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);
        }