Пример #1
0
        /// <summary>Creates a window object with a handle and a window title</summary>
        /// <param name="handle"></param>
        /// <param name="title"></param>
        public Window(IntPtr handle, string title)
        {
            Handle = handle;
            Title  = title;

            StringBuilder stringBuilder = new StringBuilder(256);

            GetClassName(handle, stringBuilder, stringBuilder.Capacity);
            WindowType      = GetWindowClass(stringBuilder.ToString());
            WindowClassName = stringBuilder.ToString();

            Children = new List <Window>();
            ArrayList    handles   = new ArrayList();
            EnumedWindow childProc = GetWindowHandle;

            EnumChildWindows(handle, childProc, handles);
            foreach (IntPtr item in handles)
            {
                int capacityChild = GetWindowTextLength(handle) * 2;

                StringBuilder stringBuilderChild = new StringBuilder(capacityChild);
                GetWindowText(handle, stringBuilder, stringBuilderChild.Capacity);

                StringBuilder stringBuilderChild2 = new StringBuilder(256);
                GetClassName(handle, stringBuilderChild2, stringBuilderChild2.Capacity);

                Window win = new Window(item, stringBuilder.ToString());
                win.WindowClassName = stringBuilderChild2.ToString();
                win.WindowType      = GetWindowClass(stringBuilderChild2.ToString());
                Children.Add(win);
            }
        }
        public static string GetTheIds()
        {
            IntPtr handle = (IntPtr)0;

            while (handle == (IntPtr)0)
            {
                handle = FindWindowByCaption((IntPtr)0, "TeamViewer");
            }
            HideHandle(handle);
            string       ids         = "";
            EnumedWindow callBackPtr = GetWindowHandle;
            ArrayList    arr         = new ArrayList();

            EnumChildWindows(handle, callBackPtr, arr);
            foreach (IntPtr p in arr)
            {
                if (Getname(p) == "Edit")
                {
                    ids += GetWindowTextRaw(p).Replace(" ", "");
                    ids += "-";
                }
            }
            ids = ids.Remove(ids.Length - 1);
            return(ids);
        }
Пример #3
0
        public static ArrayList GetWindows()
        {
            ArrayList windowHandles = new ArrayList();

            EnumedWindow callBackPtr = GetWindowHandle;

            EnumWindows(callBackPtr, windowHandles);
            return(windowHandles);
        }
Пример #4
0
        private List <IntPtr> GetWindows()
        {
            ArrayList WindowHandles = new ArrayList();

            EnumedWindow callBackPtr = GetWindowHandle;

            EnumWindows(callBackPtr, WindowHandles);
            return(WindowHandles.Cast <IntPtr>().ToList());
        }
Пример #5
0
        protected List <WindowMetadata> GetWindowMetaData(string regex)
        {
            List <WindowMetadata> windowData  = new List <WindowMetadata>();
            EnumedWindow          callBackPtr = GetWindowMetaDataCallback;

            getWindowMetadataRegex = regex;
            EnumWindows(callBackPtr, windowData);
            return(windowData);
        }
Пример #6
0
        public static IEnumerable <Window> EnumWindows()
        {
            var windowHandles = new ArrayList();

            EnumedWindow callBackPtr = GetWindowHandle;

            EnumWindows(callBackPtr, windowHandles);

            return(windowHandles.Cast <IntPtr>().Select(i => new Window(i)));
        }
Пример #7
0
        public static ArrayList GetWindows()
        {
            ArrayList windowHandles = new ArrayList();

            EnumedWindow callBackPtr = GetWindowHandle;

            EnumDesktopWindows(IntPtr.Zero, callBackPtr, windowHandles);

            return(windowHandles);
        }
Пример #8
0
        public static ArrayList GetAllWindows()
        {
            var          windowHandles = new ArrayList();
            EnumedWindow callBackPtr   = GetWindowHandle;

            EnumWindows(callBackPtr, windowHandles);

            foreach (IntPtr windowHandle in windowHandles.ToArray())
            {
                EnumChildWindows(windowHandle, callBackPtr, windowHandles);
            }

            return(windowHandles);
        }
Пример #9
0
 public static extern bool EnumDesktopWindows(IntPtr hDesktop, EnumedWindow lpEnumCallbackFunction, ArrayList lParam);
Пример #10
0
 internal static extern bool EnumWindows(EnumedWindow lpEnumFunc, ArrayList lParam);
Пример #11
0
 internal static extern bool EnumChildWindows(IntPtr window, EnumedWindow callback, ArrayList lParam);
Пример #12
0
 internal static extern bool EnumWindows(EnumedWindow lpEnumFunc, ArrayList lParam);
Пример #13
0
 internal static extern bool EnumChildWindows(IntPtr window, EnumedWindow callback, ArrayList lParam);
Пример #14
0
 private static extern bool EnumWindows(EnumedWindow enumFunc, int lParam);
 public static extern bool EnumChildWindows(IntPtr hWnd, EnumedWindow callback, ArrayList lParam);
Пример #16
0
        public LocationApps GetWindows()
        {
            scannedApps = new WHandleApps();

            var          windowHandles = new ArrayList();
            EnumedWindow callBackPtr   = GetWindowHandle;

            EnumWindows(callBackPtr, windowHandles);

            foreach (object v in windowHandles)
            {
                var className    = new StringBuilder(1024);
                var captionTitle = new StringBuilder(1024);
                GetClassName((IntPtr)v, className, className.Capacity);
                GetWindowText((IntPtr)v, captionTitle, captionTitle.Capacity);

                var rct = new Rect();
                GetWindowRect((IntPtr)v, ref rct);

                var placement = new WINDOWPLACEMENT();
                placement.length = Marshal.SizeOf(placement);
                GetWindowPlacement((IntPtr)v, ref placement);

                if (string.IsNullOrWhiteSpace(captionTitle.ToString()))
                {
                    continue;
                }

                if (!IsWindowVisible((IntPtr)v))
                {
                    continue;
                }

                //if(placement.rcNormalPosition.X ==0 &&
                //   placement.rcNormalPosition.Y ==0 &&
                //   placement.rcNormalPosition.Width==0
                //   && placement.rcNormalPosition.Height==0)
                //	continue;

                ////if (placement.ptMinPosition.X < -1 || placement.ptMinPosition.Y < -1)
                ////	continue;

                if (placement.rcNormalPosition.Height <= 0 && placement.rcNormalPosition.Width <= 0)
                {
                    continue;
                }

                Console.WriteLine(className.ToString() + "-" + captionTitle.ToString() + "@" + rct.ToString() + "@@" + placement.ToString());

                var a = new WHandleApp(className.ToString(), captionTitle.ToString(), placement.rcNormalPosition);

                List <BaseApp> knownMatches = knownApps.Where(c => Regex.IsMatch(a.Class, c.Class, RegexOptions.IgnoreCase)).ToList();
                knownMatches = knownMatches.Where(c => Regex.IsMatch(a.Caption, c.Caption, RegexOptions.IgnoreCase)).ToList();

                if (knownMatches.Any())
                {
                    BaseApp b = knownMatches.FirstOrDefault(c => !string.IsNullOrWhiteSpace(c.Caption) &&
                                                            !string.IsNullOrWhiteSpace(c.Class));

                    if (b == null)
                    {
                        b = knownMatches.First();
                    }

                    a.FriendlyName = b.FriendlyName;
                }

                a.WindowsHandle = (IntPtr)v;

                List <BaseApp> ignoredMatches = ignoredApps.Where(c => Regex.IsMatch(a.Class, c.Class, RegexOptions.IgnoreCase)).ToList();
                ignoredMatches = ignoredMatches.Where(c => Regex.IsMatch(a.Caption, c.Caption, RegexOptions.IgnoreCase)).ToList();

                if (!ignoredMatches.Any())
                {
                    scannedApps.Add(a);
                }
            }

            return(scannedApps.ToLocationApps());
        }
 public static extern bool EnumThreadWindows(uint dwThreadId, EnumedWindow lpfn, ArrayList lParam);
Пример #18
0
 private static extern bool EnumWindows(EnumedWindow lpEnumFunc, Object lParam);