Ejemplo n.º 1
0
        private static IntPtr HookCallBack(int nCode, IntPtr wParam, IntPtr lParam)
        {
            IntPtr res    = CallNextHookEx(_hookID, nCode, wParam, lParam);
            Keys   vkCode = (Keys)Marshal.ReadInt32(lParam);

            if (nCode >= 0 && bSendKey > 0)
            {
                Console.WriteLine(bSendKey.ToString() + " STATE : " + MultiKeyGesture.keyState() + " -> " + vkCode.ToString());
                bSendKey--;
                return(res);
            }

            if (nCode >= 0 && wParam == (IntPtr)WM_KEYDOWN)
            {
                MultiKeyGesture.keyDown(vkCode);
                if (keyMapping(vkCode))
                {
                    res = (IntPtr)1;
                }
            }

            if (nCode >= 0 && (wParam == (IntPtr)WM_KEYUP))
            {
                MultiKeyGesture.keyUp(vkCode);
            }
            return(res);
        }
Ejemplo n.º 2
0
        public static string getSelection()
        {
            try
            {
                string prevClipboardText = Clipboard.GetText();
                MultiKeyGesture.sendKeyAvoidHook("^c");
                Thread.Sleep(100);

                string selectedText = Clipboard.GetText();
                selectedText = selectedText.Trim();
                selectedText = selectedText.Replace(Environment.NewLine, " ");

                Clipboard.SetText(prevClipboardText);
                if (prevClipboardText == selectedText)
                {
                    return("");
                }
                else
                {
                    return(selectedText);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return("");
            }
        }
Ejemplo n.º 3
0
        private static bool keyMapping(Keys key, bool peek = false)
        {
            if (MultiKeyGesture.bMatched)
            {
                return(true);
            }

            foreach (var shortcut in multiKeyGestureList)
            {
                if (MultiKeyGesture.keyMatch(shortcut.Key, peek))
                {
                    if (!peek)
                    {
                        switch (shortcut.Value)
                        {
                        case "Find":
                            ShortCutManager.find();
                            break;

                        case "Translate":
                            ShortCutManager.translate();
                            break;

                        case "Exit":
                            ShortCutManager.exit();
                            break;

                        case "Test":
                            Console.WriteLine("Test Line");
                            break;
                        }
                    }
                    return(true);
                }
            }
            return(false);
        }