Exemplo n.º 1
0
 /// <summary>
 /// Gets info of a menu item from point.
 /// Returns null if fails, eg the point is not in the menu or the window is hung.
 /// </summary>
 /// <param name="pScreen">Point in screen coordinates.</param>
 /// <param name="w">Popup menu window, class name "#32768".</param>
 /// <param name="msTimeout">Timeout (ms) to use when the window is busy or hung.</param>
 public static MenuItemInfo FromXY(POINT pScreen, wnd w, int msTimeout = 5000)
 {
     if (!w.SendTimeout(msTimeout, out var hm, Api.MN_GETHMENU))
     {
         return(null);
     }
     int i = Api.MenuItemFromPoint(default, hm, pScreen); if (i == -1)
Exemplo n.º 2
0
            /// <summary>
            /// Waits until the target app gets (Paste) or sets (Copy) clipboard text.
            /// Throws AuException on timeout (3 s normally, 28 s if the target window is hung).
            /// </summary>
            /// <param name="ctrlKey">The variable that was used to send Ctrl+V or Ctrl+C. This function may call Release to avoid too long Ctrl down.</param>
            public void Wait(ref keys.Internal_.SendCopyPaste ctrlKey)
            {
                //print.it(Success); //on Paste often already true, because SendInput dispatches sent messages
                for (int n = 6; !Success;)                   //max 3 s (6*500 ms). If hung, max 28 s.
                {
                    wait.Wait_(500, WHFlags.DoEvents, null, this);

                    if (Success)
                    {
                        break;
                    }
                    //is hung?
                    if (--n == 0)
                    {
                        throw new AuException(_paste ? "*paste" : "*copy");
                    }
                    ctrlKey.Release();
                    _wFocus.SendTimeout(5000, out _, 0, flags: 0);
                }
            }
Exemplo n.º 3
0
        /// <summary>
        /// Gets control name.
        /// Returns null if fails or the name is empty.
        /// </summary>
        /// <param name="c">The control. Can be a top-level window too. Must be of the same process as the window specified in the constructor.</param>
        public string GetControlName(wnd c)
        {
            if (_pm == null)
            {
                return(null);
            }
            if (!IsWinformsControl(c))
            {
                return(null);
            }
            if (!c.SendTimeout(5000, out var R, WM_GETCONTROLNAME, 4096, _pm.Mem) || (int)R < 1)
            {
                return(null);
            }
            int len = (int)R - 1;

            if (len == 0)
            {
                return("");
            }
            return(_pm.ReadCharString(len));
        }