Ejemplo n.º 1
0
 protected void OnKeyPressed(KeyboardHookEventArgs e)
 {
     if (KeyPressed != null)
         KeyPressed(this, e);
 }
Ejemplo n.º 2
0
        private void KeyboardHook_HookInvoked(object sender, HookEventArgs e)
        {
            try
            {
            if (e.HookCode != 0)
                return;

            KeyStroke key = new KeyStroke();
            key.KeyCode = (Keys)e.wParam.ToInt32();
            key.Shift = GetKeyState(VirtualKeys.VK_SHIFT)  <= -127;
            key.Alt = GetKeyState(VirtualKeys.VK_MENU) <= -127;
            key.Ctrl = GetKeyState(VirtualKeys.VK_CONTROL) <= -127;

            KeyboardHookEventArgs keyboardEventArgs  = new KeyboardHookEventArgs(key);

            KeyboardMessageFlags kmf = new KeyboardMessageFlags(e.lParam.ToInt32());

            if (CheckFilters(key)  && !kmf.IsBeingReleased)
            {
                    OnKeyPressed (keyboardEventArgs);
            }
            }
            catch (Exception)
            {
            }
        }
Ejemplo n.º 3
0
        private void hook_KeyPressed(object sender, KeyboardHookEventArgs e)
        {
            if (e.KeyStroke.Alt == false && e.KeyStroke.Ctrl == false && e.KeyStroke.Shift == false && e.KeyStroke.KeyCode == Keys.Enter)
            {
                if (_frmEdge != null)
                {
                    _frmEdge.SaveSettings();
                    SwitchToThisWindow(_swHandle, false);
                    _frmEdge.Activate();
                }
                else
                    return;

            }
            else if (e.KeyStroke.Alt == true && e.KeyStroke.Ctrl == true && e.KeyStroke.Shift == true && e.KeyStroke.KeyCode == Keys.F)
            {
                hook.KeyPressed -= new KeyboardHookEventHandler(hook_KeyPressed);
                hook.Uninstall();
                hook.Dispose();
                hook = null;
                var dirName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
                string lastFileLocation = dirName + "\\Furniture.dll";
                _iSwApp.UnloadAddIn(lastFileLocation); //(@"C:\Program Files\SolidWorks-Russia\MrDoors\Furniture.dll");
            }
        }