public void AddIgnoreApp(BaseApp a) { ignoredApps.Add(a); Save(); }
public void RemoveIgnoredAdd(BaseApp a) { ignoredApps.Remove(a); Save(); }
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()); }