Beispiel #1
0
        public static SearchCriteria FromString(string mixed)
        {
            if(mixed.IndexOf(Core.Keyword_ahk, StringComparison.OrdinalIgnoreCase) == -1)
                return new SearchCriteria { Title = mixed };

            var criteria = new SearchCriteria();
            var i = 0;
            var t = false;

            while((i = mixed.IndexOf(Core.Keyword_ahk, i, StringComparison.OrdinalIgnoreCase)) != -1) {
                if(!t) {
                    var pre = i == 0 ? string.Empty : mixed.Substring(0, i).Trim(Core.Keyword_Spaces);

                    if(pre.Length != 0)
                        criteria.Title = pre;

                    t = true;
                }

                var z = mixed.IndexOfAny(Core.Keyword_Spaces, i);

                if(z == -1)
                    break;

                var word = mixed.Substring(i, z - i);

                var e = mixed.IndexOf(Core.Keyword_ahk, ++i, StringComparison.OrdinalIgnoreCase);
                var arg = (e == -1 ? mixed.Substring(z) : mixed.Substring(z, e - z)).Trim();
                long n;

                switch(word.ToLowerInvariant()) {
                    case Core.Keyword_ahk_class: criteria.ClassName = arg; break;
                    case Core.Keyword_ahk_group: criteria.Group = arg; break;

                    case Core.Keyword_ahk_id:
                        if(long.TryParse(arg, out n))
                            criteria.ID = new IntPtr(n);
                        break;

                    case Core.Keyword_ahk_pid:
                        if(long.TryParse(arg, out n))
                            criteria.PID = new IntPtr(n);
                        break;
                }

                i++;
            }

            return criteria;
        }
        public override SystemWindow FindWindow(SearchCriteria criteria)
        {
            SystemWindow found = null;

            if(criteria.IsEmpty)
                return found;

            if(!string.IsNullOrEmpty(criteria.ClassName) && !criteria.HasExcludes && !criteria.HasID && string.IsNullOrEmpty(criteria.Text))
                found = new WindowWindows(WindowsAPI.FindWindow(criteria.ClassName, criteria.Title));
            else {
                foreach(var window in AllWindows) {
                    if(window.Equals(criteria)) {
                        found = window;
                        break;
                    }
                }
            }

            if(found.IsSpecified)
                LastFound = found;

            return found;
        }
 public override SystemWindow FindWindow(SearchCriteria criteria)
 {
     throw new NotImplementedException();
 }
Beispiel #4
0
        public bool Equals(SearchCriteria criteria)
        {
            if(!IsSpecified)
                return false;

            if(criteria.ID != IntPtr.Zero && this.Handle != criteria.ID)
                return false;

            if(criteria.PID != IntPtr.Zero && PID != criteria.PID)
                return false;

            var comp = StringComparison.OrdinalIgnoreCase;

            if(!string.IsNullOrEmpty(criteria.ClassName)) {
                if(!ClassName.Equals(criteria.ClassName, comp))
                    return false;
            }

            if(!string.IsNullOrEmpty(criteria.Title)) {
                if(!TitleCompare(Title, criteria.Title))
                    return false;
            }

            if(!string.IsNullOrEmpty(criteria.Text)) {
                foreach(var text in Text)
                    if(text.IndexOf(criteria.Text, comp) == -1)
                        return false;
            }

            if(!string.IsNullOrEmpty(criteria.ExcludeTitle)) {
                if(Title.IndexOf(criteria.ExcludeTitle, comp) != -1)
                    return false;
            }

            if(!string.IsNullOrEmpty(criteria.ExcludeText)) {
                foreach(var text in Text)
                    if(text.IndexOf(criteria.ExcludeText, comp) != -1)
                        return false;
            }

            return true;
        }
Beispiel #5
0
 public abstract SystemWindow FindWindow(SearchCriteria criteria);