コード例 #1
0
        /// <summary>Emulates a foreground key press.</summary>
        /// <param name="hWnd">The handle to the window that will receive the key press.</param>
        /// <returns>Returns whether the key succeeded to be pressed or not.</returns>
        public bool PressForeground(IntPtr hWnd)
        {
            bool alt = false, ctrl = false, shift = false;

            switch (ShiftType)
            {
            case Messaging.ShiftType.ALT:
                alt = true;
                break;

            case Messaging.ShiftType.CTRL:
                ctrl = true;
                break;

            case Messaging.ShiftType.NONE:
                if (!Messaging.ForegroundKeyPress(hWnd, this))
                {
                    _buttonCounter++;
                    if (_buttonCounter == 2)
                    {
                        _buttonCounter = 0;
                        return(false);
                    }
                    PressForeground(hWnd);
                }
                return(true);

            case Messaging.ShiftType.SHIFT:
                shift = true;
                break;
            }
            if (!Messaging.ForegroundKeyPressAll(hWnd, this, alt, ctrl, shift))
            {
                _buttonCounter++;
                if (_buttonCounter == 2)
                {
                    _buttonCounter = 0;
                    return(false);
                }
                PressForeground(hWnd);
            }
            return(true);
        }
コード例 #2
0
 public bool PressForeground()
 {
     switch (ShiftType)
     {
     case Messaging.ShiftType.NONE:
         if (!Messaging.ForegroundKeyPress(this))
         {
             _buttonCounter++;
             if (_buttonCounter == 2)
             {
                 _buttonCounter = 0;
                 return(false);
             }
             PressForeground();
         }
         return(true);
     }
     return(true);
 }
コード例 #3
0
ファイル: Key.cs プロジェクト: tobster-de/Keyboard
        /// <summary>Emulates a foreground key press.</summary>
        /// <param name="hWnd">The handle to the window that will receive the key press.</param>
        /// <returns>Returns whether the key succeeded to be pressed or not.</returns>
        public bool PressForeground(IntPtr hWnd)
        {
            bool alt   = (this.ShiftType & MessagingApi.ShiftType.ALT) != 0;
            bool ctrl  = (this.ShiftType & MessagingApi.ShiftType.CTRL) != 0;
            bool shift = (this.ShiftType & MessagingApi.ShiftType.SHIFT) != 0;

            int counter = 0;

            while (counter < RetryCount)
            {
                if (Messaging.ForegroundKeyPress(hWnd, this, alt, ctrl, shift))
                {
                    return(true);
                }

                counter++;
            }

            return(false);
        }
コード例 #4
0
ファイル: Key.cs プロジェクト: tobster-de/Keyboard
        public bool PressForeground()
        {
            if (this.ShiftType != MessagingApi.ShiftType.NONE)
            {
                return(false);
            }

            int counter = 0;

            while (counter < RetryCount)
            {
                if (Messaging.ForegroundKeyPress(this))
                {
                    return(true);
                }

                counter++;
            }

            return(false);
        }