Ejemplo n.º 1
0
        /// <summary>
        /// See <see cref="wnd.Child"/>.
        /// </summary>
        /// <exception cref="ArgumentException">See <see cref="wnd.Child"/>.</exception>
        public wndChildFinder(
            [ParamString(PSFormat.Wildex)] string name = null,
            [ParamString(PSFormat.Wildex)] string cn   = null,
            WCFlags flags = 0, int?id = null, Func <wnd, bool> also = null, int skip = 0
            )
        {
            if (cn != null)
            {
                if (cn.Length == 0)
                {
                    throw new ArgumentException("Class name cannot be \"\". Use null.");
                }
                _className = cn;
            }
            if (name != null)
            {
                switch (StringUtil.ParseParam3Stars(ref name, "text", "elmName", "wfName" /*, "label"*/))
                {
                case -1: throw new ArgumentException("Invalid name prefix. Can be: \"***text \", \"***elmName \", \"***wfName \".");                 //, \"***label \"

                case 1: _nameIs = _NameIs.text; break;

                case 2: _nameIs = _NameIs.elmName; break;

                case 3: _nameIs = _NameIs.wfName; break;
                    //case 4: _nameIs = _NameIs.label; break;
                }
                _name = name;
            }
            _flags     = flags;
            _id        = id;
            _also      = also;
            _skipCount = skip;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Finds all matching child controls.
        /// Everything except the return type is the same as with <see cref="Child"/>.
        /// </summary>
        /// <returns>List containing 0 or more control handles as <see cref="wnd"/>.</returns>
        /// <exception cref="AuWndException"/>
        /// <exception cref="ArgumentException"/>
        /// <remarks>
        /// In the returned list, hidden controls (when using WCFlags.HiddenToo) are always after visible controls.
        /// </remarks>
        /// <seealso cref="getwnd.Children"/>
        public wnd[] ChildAll(
            [ParamString(PSFormat.Wildex)] string name = null,
            [ParamString(PSFormat.Wildex)] string cn   = null,
            WCFlags flags = 0, int?id = null, Func <wnd, bool> also = null)
        {
            //ThrowIfInvalid(); //will be called later
            var f = new wndChildFinder(name, cn, flags, id, also);

            return(f.FindAll(this));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Finds a child control and returns its handle as AWnd.
        /// </summary>
        /// <returns>Returns <c>default(AWnd)</c> if not found. See also: <see cref="Is0"/>, <see cref="operator +(AWnd)"/>.</returns>
        /// <param name="name">
        /// Control name.
        /// String format: [](xref:wildcard_expression).
        /// null means 'can be any'. "" means 'no name'.
        ///
        /// By default to get control names this function uses <see cref="Name"/>.
        /// Can start with these prefix strings:
        /// - <c>"***text "</c> - use <see cref="ControlText"/>. Slower and less reliable because can get editable text. If a character can be underlined with Alt, insert '&amp;' before it.
        /// - <c>"***accName "</c> - use <see cref="NameAcc"/>. Slower.
        /// - <c>"***wfName "</c> - use .NET Forms control name (see <see cref="AWinFormsControlNames"/>). Slower and can fail because of [](xref:uac).
        /// - <c>"***id "</c> like <c>"***id 15"</c> - use control id (<see cref="ControlId"/>). See also <see cref="ChildById"/>.
        /// </param>
        /// <param name="cn">
        /// Control class name.
        /// String format: [](xref:wildcard_expression).
        /// null means 'can be any'. Cannot be "".
        /// </param>
        /// <param name="flags"></param>
        /// <param name="also">
        /// Callback function. Called for each matching control.
        /// It can evaluate more properties of the control and return true when they match.
        /// Example: <c>also: t =&gt; t.IsEnabled</c>
        /// </param>
        /// <param name="skip">
        /// 0-based index of matching control.
        /// For example, if 1, the function skips the first matching control and returns the second.
        /// </param>
        /// <exception cref="AuWndException">This variable is invalid (window not found, closed, etc).</exception>
        /// <exception cref="ArgumentException">
        /// - <i>name</i> starts with <c>"***"</c>, but the prefix is invalid.
        /// - <i>cn</i> is "". To match any, use null.
        /// - Invalid wildcard expression (<c>"**options "</c> or regular expression).
        /// </exception>
        /// <remarks>
        /// To create code for this function, use dialog "Find window or control". It is form <b>Au.Tools.FormAWnd</b> in Au.Tools.dll.
        /// </remarks>
        public AWnd Child(
            [ParamString(PSFormat.AWildex)] string name = null,
            [ParamString(PSFormat.AWildex)] string cn   = null,
            WCFlags flags = 0, Func <AWnd, bool> also = null, int skip = 0)
        {
            //ThrowIfInvalid(); //will be called later
            var f = new ChildFinder(name, cn, flags, also, skip);

            f.Find(this);
            return(f.Result);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Returns true if this window contains the specified control.
 /// Calls <see cref="Child"/>.
 /// <note>
 /// Using this function many times with same parameters is inefficient. Instead create new <see cref="ChildFinder"/> and call <see cref="ChildFinder.Find"/> or <see cref="HasChild(ChildFinder)"/>. See example.
 /// </note>
 /// </summary>
 /// <exception cref="AuWndException"/>
 /// <exception cref="ArgumentException"/>
 /// <example>
 /// <code><![CDATA[
 /// //find window that contains certain control, and get the control too
 /// var f = new AWnd.ChildFinder("Password*", "Static"); //control properties
 /// AWnd w = AWnd.Find(cn: "#32770", also: t => t.HasChild(f));
 /// AOutput.Write(w);
 /// AOutput.Write(f.Result);
 /// ]]></code>
 /// </example>
 public bool HasChild(
     [ParamString(PSFormat.AWildex)] string name = null,
     [ParamString(PSFormat.AWildex)] string cn   = null,
     WCFlags flags = 0, Func <AWnd, bool> also = null, int skip = 0)
 {
     return(default != Child(name, cn, flags, also, skip));
Ejemplo n.º 5
0
 /// <summary>
 /// Finds a child control and returns its handle as <see cref="wnd"/>. Can wait and throw <b>NotFoundException</b>.
 /// </summary>
 /// <returns>Child control handle. If not found, throws exception or returns <c>default(wnd)</c> (if <i>waitS</i> negative).</returns>
 /// <param name="waitS">The wait timeout, seconds. If 0, does not wait. If negative, does not throw exception when not found.</param>
 /// <param name="name"></param>
 /// <param name="cn"></param>
 /// <param name="flags"></param>
 /// <param name="id"></param>
 /// <param name="also"></param>
 /// <param name="skip"></param>
 /// <exception cref="AuWndException">This variable is invalid (window not found, closed, etc). Or closed while waiting.</exception>
 /// <exception cref="ArgumentException" />
 /// <exception cref="NotFoundException" />
 public wnd Child(
     double waitS,
     [ParamString(PSFormat.Wildex)] string name = null,
     [ParamString(PSFormat.Wildex)] string cn   = null,
     WCFlags flags = 0, int?id = null, Func <wnd, bool> also = null, int skip = 0
     ) => new wndChildFinder(name, cn, flags, id, also, skip).Find(this, waitS);