Ejemplo n.º 1
0
        public static bool IsInWindowList(IntPtr hwnd)
        {
            AWindow awin = windowList.FirstOrDefault(awindow => awindow.Hwnd == hwnd);

            if (awin != null)
            {
                return(true);
            }
            return(false);
        }
Ejemplo n.º 2
0
        public static void AddAWindow(AWindow awin)
        {
            if (string.IsNullOrEmpty(awin.Title) == false)
            {
                if (awin.Title == "SET_WINDOW")
                {
                    return;
                }
                if (awin.Title == "Program Manager")
                {
                    return;
                }
                windowList.Add(awin);

                //infoString = "Added Window: " + awin.title + " (" + awin.hwnd.ToString() + ")";
            }
        }
Ejemplo n.º 3
0
        public static void RestoreWindow(AWindow awin)
        {
            int oldX      = awin.SavedRECT.Left;
            int oldY      = awin.SavedRECT.Top;
            int oldWidth  = awin.SavedRECT.Right - awin.SavedRECT.Left;
            int oldHeight = awin.SavedRECT.Bottom - awin.SavedRECT.Top;

            WINDOWPLACEMENT placement = new WINDOWPLACEMENT();

            placement = awin.Placement;
            SetWindowPlacement(awin.Hwnd, ref placement);
            SetWindowPos(awin.Hwnd,
                         WinLib.HWND.HWND_BOTTOM,
                         oldX, oldY,
                         oldWidth, oldHeight,
                         WinLib.SWP.SWP_NOOWNERZORDER);
        }
Ejemplo n.º 4
0
        public static void EnumAllWindows()
        {
            windowList.Clear();
            DesktopWindowHandle = GetDesktopWindow();

            EnumDelegate filter = delegate(IntPtr hWnd, int lParam)
            {
                AWindow awin = GetAWINDOW(hWnd);
                if (IsWindowVisible(hWnd) && string.IsNullOrEmpty(awin.Title) == false)
                {
                    AddAWindow(awin);
                }

                return(true);
            };

            if (EnumDesktopWindows(IntPtr.Zero, filter, IntPtr.Zero))
            {
                //success
            }
        }
Ejemplo n.º 5
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);
        }