Exemple #1
0
        public WindowsMessageListener(KeyboardHook kbHook)
        {
            this.kbHook = kbHook;

            KeyboardHook.Modifiers modifiers = 0;

            Keys k = Keys.Space | Keys.Control;

            if ((k & Keys.Alt) == Keys.Alt)
            {
                modifiers = modifiers | KeyboardHook.Modifiers.MOD_ALT;
            }

            if ((k & Keys.Control) == Keys.Control)
            {
                modifiers = modifiers | KeyboardHook.Modifiers.MOD_CONTROL;
            }

            if ((k & Keys.Shift) == Keys.Shift)
            {
                modifiers = modifiers | KeyboardHook.Modifiers.MOD_SHIFT;
            }

            k = k & ~Keys.Control & ~Keys.Shift & ~Keys.Alt;

            kbHook.RegHotKey(modifiers, (uint)k, this.Handle, this.GetHashCode());
        }
Exemple #2
0
        public MainProgram()
        {
            replacementMap = new Dictionary <char, char>()
            {
                { 'c', 'ĉ' },
                { 'C', 'Ĉ' },
                { 'g', 'ĝ' },
                { 'G', 'Ĝ' },
                { 'j', 'ĵ' },
                { 'J', 'Ĵ' },
                { 's', 'ŝ' },
                { 'S', 'Ŝ' },
                { 'u', 'ŭ' },
                { 'U', 'Ŭ' },
                { 'h', 'ĥ' },
                { 'H', 'Ĥ' }
            };
            onIcon  = new System.Drawing.Icon("greenstar2.ico");
            offIcon = new System.Drawing.Icon("graystar.ico");

            cm = new ContextMenu();
            cm.MenuItems.Add("Malŝalti", new EventHandler(Toggle_OnClick));
            cm.MenuItems.Add("Fermi", new EventHandler(Close_onClick));

            ni             = new NotifyIcon();
            ni.Icon        = onIcon;
            ni.ContextMenu = cm;
            ni.Text        = "Esperanta Klavaro";
            ni.Visible     = true;

            KeyboardHook.Modifiers modifiers = KeyboardHook.Modifiers.MOD_CONTROL;

            Keys k = Keys.Space;

            kbHook = new KeyboardHook(modifiers, k);

            kbHook.KeyPressed += new KeyPressEventHandler(KeyPressHandler);

            kbHook.HotKeyPressed += new EventHandler(Toggle_OnClick);
        }