Ejemplo n.º 1
0
        /// <summary>
        ///     Callback called by Form to initaite press of hotkey
        /// </summary>
        /// <param name="kea">KeyboardHookEventArgs event args</param>
        public void KeyCallback(KeyboardHookEventArgs kea)
        {
            // key and modifers match?
            WinAuthAuthenticator match = null;

            foreach (var auth in m_hooked)
            {
                if ((Keys)auth.HotKey.Key == kea.Key && auth.HotKey.Modifiers == kea.Modifiers)
                {
                    match = auth;
                    break;
                }
            }

            if (match == null)
            {
                return;
            }
            kea.Authenticator = match;

            // call user events
            if (KeyPressed != null)
            {
                KeyPressed(this, kea);
            }
        }
Ejemplo n.º 2
0
		/// <summary>
		/// A hotkey keyboard event occured, e.g. "Ctrl-Alt-C"
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		void Hotkey_KeyPressed(object sender, KeyboardHookEventArgs e)
		{
			// avoid multiple keypresses being sent
			if (e.Authenticator != null && Monitor.TryEnter(m_sendingKeys) == true)
			{
				try
				{
					// set Tag as HotKeyLauncher so we can pull back related authenticator and check for timeout
					hotkeyTimer.Tag = new HotKeyLauncher(this, e.Authenticator);
					hotkeyTimer.Enabled = true;

					// mark event as handled
					e.Handled = true;
				}
				finally
				{
					Monitor.Exit(m_sendingKeys);
				}
			}
		}
Ejemplo n.º 3
0
		/// <summary>
		/// Callback called by Form to initaite press of hotkey
		/// </summary>
		/// <param name="kea">KeyboardHookEventArgs event args</param>
		public void KeyCallback(KeyboardHookEventArgs kea)
		{
			// key and modifers match?
			WinAuthAuthenticator match = null;
			foreach (var auth in m_hooked)
			{
				if ((Keys)auth.HotKey.Key == kea.Key && auth.HotKey.Modifiers == kea.Modifiers)
				{
					match = auth;
					break;
				}
			}
			if (match == null)
			{
				return;
			}
			kea.Authenticator = match;

			// call user events
			if (KeyPressed != null)
			{
				KeyPressed(this, kea);
			}
		}