Пример #1
0
        private void WinList(TFunctionData parameters)
        {
            if (parameters.ParameterCount == 1)
            {
                parameters.AddParameter(WindowFlag.Existing);
            }
            parameters.AssertParamCount(2);
            WindowFlag state = parameters.GetParameter <WindowFlag>(1);

            IntPtr[] hwnds = WinList(state).ToArray();

            if (hwnds.Length > 0)
            {
                object[][] windows = new object[hwnds.Length][];
                for (int index = 0; index < windows.Length; index++)
                {
                    windows[index] = new object[] {
                        Evaluator.ConvertToObject(hwnds[index]),
                        WinGetTitle(hwnds[index])
                    };
                }
                parameters.Data = windows;
            }
            else
            {
                parameters.Status = ErrorSuccess.NoContent;
            }
        }
Пример #2
0
        public static WindowFlag GetState(IntPtr hwnd)
        {
            IntPtr     exists = User32.GetWindow(hwnd, 0);
            WindowFlag state  = WindowFlag.Existing;

            if (exists == IntPtr.Zero)
            {
                return(0);
            }
            if (User32.IsWindowVisible(hwnd))
            {
                state |= WindowFlag.Visible;
            }
            if (User32.IsWindowEnabled(hwnd))
            {
                state |= WindowFlag.Enable;
            }
            if (User32.GetForegroundWindow() == hwnd)
            {
                state |= WindowFlag.Active;
            }
            WINDOWPLACEMENT plac;

            User32.GetWindowPlacement(hwnd, out plac);
            if (plac.showCmd == 2)
            {
                state |= WindowFlag.Minimized;
            }
            if (plac.showCmd == 3)
            {
                state |= WindowFlag.Maximized;
            }
            return(state);
        }
Пример #3
0
        public static IEnumerable <IntPtr> List(WindowFlag flag)
        {
            var results =
                from hwnd in List()
                where (GetState(hwnd) & flag) == flag
                select hwnd;

            return(results);
        }
Пример #4
0
 public static IEnumerable <IntPtr> WinList(WindowFlag flag = WindowFlag.None)
 {
     if (flag == 0)
     {
         return(Windows.List());
     }
     else
     {
         return(Windows.List(flag));
     }
 }