Esempio n. 1
0
 /// <summary>
 /// 绘制光标
 /// </summary>
 /// <param name="g"></param>
 public static void DrawMouse(Graphics g)
 {
     try
     {
         CURSORINFO pci;
         pci.cbSize = Marshal.SizeOf(typeof(CURSORINFO));
         MouseAndKeyHelper.GetCursorInfo(out pci);
         Cursor cur = new Cursor(pci.hCursor);
         cur.Draw(g, new Rectangle(pci.ptScreenPos.X, pci.ptScreenPos.Y, cur.Size.Width, cur.Size.Height));
     }
     catch { }
 }
Esempio n. 2
0
        /// <summary>
        /// 注册热键
        /// </summary>
        /// <param name="control"></param>
        /// <param name="hasCtrl"></param>
        /// <param name="hasAlt"></param>
        /// <param name="hasShift"></param>
        /// <param name="key"></param>
        /// <returns></returns>
        public static bool RegistHotKeys(Control control, bool hasCtrl, bool hasAlt, bool hasShift, string key, int hotKeyID)
        {
            bool result = false;

            MouseAndKeyHelper.UnregisterHotKey(control.Handle, hotKeyID);

            comboKeys = 0 | (hasCtrl ? MOD_CONTROL : 0) | (hasAlt ? MOD_ALT : 0) | (hasShift ? MOD_SHIFT : 0);

            uint keyCode = Convert.ToUInt32((Keys)Enum.Parse(typeof(Keys), key));

            if (MouseAndKeyHelper.RegisterHotKey(control.Handle, hotKeyID, comboKeys, keyCode))
            {
                result = true;
            }
            else
            {
                //throw new Exception("注册热键失败!");
            }
            return(result);
        }