예제 #1
0
파일: LLHook.cs 프로젝트: palashman/Mahou
        public static IntPtr Callback(int nCode, IntPtr wParam, IntPtr lParam)
        {
            if (MMain.mahou == null || nCode < 0)
            {
                return(WinAPI.CallNextHookEx(_LLHook_ID, nCode, wParam, lParam));
            }
            if (KMHook.ExcludedProgram() && !MahouUI.ChangeLayoutInExcluded)
            {
                return(WinAPI.CallNextHookEx(_LLHook_ID, nCode, wParam, lParam));
            }
            var vk  = Marshal.ReadInt32(lParam);
            var Key = (Keys)vk;

            SetModifs(Key, wParam);
            if (MahouUI.SnippetsEnabled)
            {
                if (KMHook.c_snip.Count > 0)
                {
                    if (MMain.mahou.SnippetsExpandType == "Tab" && Key == Keys.Tab && !shift && !alt && !win && !ctrl)
                    {
                        WinAPI.keybd_event((byte)Keys.F14, (byte)Keys.F14, (int)WinAPI.KEYEVENTF_KEYUP, 0);
                        return((IntPtr)1);                        // Disable event
                    }
                }
            }
            if (MahouUI.RemapCapslockAsF18)
            {
                bool _shift = !shift, _alt = !alt, _ctrl = !ctrl, _win = !win;
                if (Key == Keys.CapsLock)
                {
                    for (int i = 1; i != 5; i++)
                    {
                        var KeyIndex = (int)typeof(MahouUI).GetField("Key" + i).GetValue(MMain.mahou);
                        if (KeyIndex == 8)                         // Shift+CapsLock
                        {
                            _shift = shift;
                        }
                    }
                }
                uint mods = 0;
                if (alt)
                {
                    mods += WinAPI.MOD_ALT;
                }
                if (ctrl)
                {
                    mods += WinAPI.MOD_CONTROL;
                }
                if (shift)
                {
                    mods += WinAPI.MOD_SHIFT;
                }
                if (win)
                {
                    mods += WinAPI.MOD_WIN;
                }
                bool has = MMain.mahou.HasHotkey(new Hotkey(false, (uint)Keys.F18, mods, 77));
                if (has)
                {
                    if (Hotkey.ContainsModifier((int)mods, (int)WinAPI.MOD_SHIFT))
                    {
                        _shift = shift;
                    }
                    if (Hotkey.ContainsModifier((int)mods, (int)WinAPI.MOD_ALT))
                    {
                        _alt = alt;
                    }
                    if (Hotkey.ContainsModifier((int)mods, (int)WinAPI.MOD_CONTROL))
                    {
                        _ctrl = ctrl;
                    }
                    if (Hotkey.ContainsModifier((int)mods, (int)WinAPI.MOD_WIN))
                    {
                        _win = win;
                    }
                }
                var GJIME = false;
                if (vk >= 240 && vk <= 242)                 // GJ IME's Shift/Alt/Ctrl + CapsLock
                {
                    GJIME = true;
                }
                //			Debug.WriteLine(Key + " " +has + "// " + _shift + " " + _alt + " " + _ctrl + " " + _win + " " + mods + " >> " + (Key == Keys.CapsLock && _shift && _alt && _ctrl && _win));
                if ((Key == Keys.CapsLock || GJIME) && _shift && _alt && _ctrl && _win)
                {
                    var flags = (int)(KInputs.IsExtended(Key) ? WinAPI.KEYEVENTF_EXTENDEDKEY : 0);
                    if (wParam == (IntPtr)WinAPI.WM_KEYUP)
                    {
                        flags |= (int)WinAPI.KEYEVENTF_KEYUP;
                    }
                    WinAPI.keybd_event((byte)Keys.F18, (byte)Keys.F18, flags, 0);
                    return((IntPtr)1);                    // Disable event
                }
                //			Debug.WriteLine(Marshal.GetLastWin32Error());
            }
            return(WinAPI.CallNextHookEx(_LLHook_ID, nCode, wParam, lParam));
        }
예제 #2
0
        /// <summary>
        /// Creates array of INPUT from string.
        /// </summary>
        /// <param name="str">String to be converted into INPUT[].</param>
        /// <returns>INPUT[]</returns>
        public static WinAPI.INPUT[] AddString(string str)
        {
            var result = new List <WinAPI.INPUT>();
            var index  = 0;

            foreach (var s in str)
            {
                bool   uselt1_vk, uselt2_vk;
                ushort resultvk = 0;
                short  lt1_vk   = WinAPI.VkKeyScanEx(s, Mahou.MahouUI.MAIN_LAYOUT1);
                uselt1_vk = lt1_vk != -1;
                short lt2_vk = WinAPI.VkKeyScanEx(s, Mahou.MahouUI.MAIN_LAYOUT2);
                uselt2_vk = lt2_vk != -1;
                if (uselt1_vk && uselt2_vk)
                {
                    var guess = Mahou.KMHook.WordGuessLayout(GetWordByIndex(str, index));
                    //              System.Diagnostics.Debug.WriteLine("ST:"+guess.Item2);
                    var lt_guess = guess.Item2;
                    resultvk = (ushort)WinAPI.VkKeyScanEx(s, lt_guess);
                }
                else if (uselt1_vk)
                {
                    resultvk = (ushort)lt1_vk;
                }
                else if (uselt2_vk)
                {
                    resultvk = (ushort)lt2_vk;
                }
                bool resultvk_state = ((resultvk >> 8) & 0xff) == 1;
                if (resultvk_state)
                {
                    result.Add(KInputs.AddKey(Keys.RShiftKey, true));
                }
                var down = new WinAPI.INPUT {
                    Type = WinAPI.INPUT_KEYBOARD,
                    Data =
                    {
                        Keyboard      = new WinAPI.KEYBDINPUT {
                            Vk        = MahouUI.GuessKeyCodeFix ? resultvk : (ushort)0,
                            Flags     = (UInt32)(WinAPI.KEYEVENTF_UNICODE),
                            Scan      = (UInt16)s,
                            ExtraInfo = IntPtr.Zero,
                            Time      = 0
                        }
                    }
                };
                var up = new WinAPI.INPUT {
                    Type = WinAPI.INPUT_KEYBOARD,
                    Data =
                    {
                        Keyboard      = new WinAPI.KEYBDINPUT {
                            Vk        = MahouUI.GuessKeyCodeFix ? resultvk : (ushort)0,
                            Flags     = (UInt32)(WinAPI.KEYEVENTF_UNICODE | WinAPI.KEYEVENTF_KEYUP),
                            Scan      = (UInt16)s,
                            ExtraInfo = IntPtr.Zero,
                            Time      = 0
                        }
                    }
                };
                if (s == '\n')
                {
                    down = AddKey(Keys.Return, true);
                    up   = AddKey(Keys.Return, false);
                }
                result.Add(down);
                result.Add(up);
                if (resultvk_state)
                {
                    result.Add(KInputs.AddKey(Keys.RShiftKey, false));
                }
                index++;
            }
            return(result.ToArray());
        }
예제 #3
0
        public static IntPtr Callback(int nCode, IntPtr wParam, IntPtr lParam)
        {
            if (MMain.mahou == null || nCode < 0)
            {
                return(WinAPI.CallNextHookEx(_LLHook_ID, nCode, wParam, lParam));
            }
            if (KMHook.ExcludedProgram() && !MahouUI.ChangeLayoutInExcluded)
            {
                return(WinAPI.CallNextHookEx(_LLHook_ID, nCode, wParam, lParam));
            }
            var vk  = Marshal.ReadInt32(lParam);
            var Key = (Keys)vk;

            if (MahouUI.BlockAltUpNOW)
            {
                if ((wParam == (IntPtr)WinAPI.WM_SYSKEYUP || wParam == (IntPtr)WinAPI.WM_KEYUP) &&
                    (Key == Keys.LMenu || Key == Keys.RMenu || Key == Keys.Menu))
                {
                    Debug.WriteLine("ihihihihihihihih-hihih-hi blocked alt :)))))");
                    MahouUI.BlockAltUpNOW = false;
                    return((IntPtr)1);
                }
            }
            SetModifs(Key, wParam);
            if ((alt || alt) && (shift || shift_r) && Key == Keys.Tab)               // mysterious Alt+Shift+Tab, sends Shift Up before Tab down!?
            {
                KMHook.skip_kbd_events++;
            }
            Debug.WriteLine("Alive" + vk + " :: " + wParam);
            #region Redefines
            if (redefines.len > 0)
            {
                var modsstr = KMHook.GetModsStr(ctrl, ctrl_r, shift, shift_r, alt, alt_r, win, win_r).Replace("+", " ").Replace("  ", "").ToLower();
                for (int i = 0; i != redefines.len; i++)
                {
                    if (Key == redefines[i].k)
                    {
                        Logging.Log("[REDEF] > Redefined: " + redefines[i].k + " => " + redefines[i].v);
                        var rli  = redefines_excl_mods[i].ToLower();
                        var redy = true;
                        if (rli == "all" && !(!shift && !alt && !ctrl && !win && !shift_r && !alt_r && !ctrl_r && !win_r))
                        {
                            redy = false;
                        }
                        else
                        {
                            var srli = rli.Split(' ');
                            for (int y = 0; y != srli.Length; y++)
                            {
                                if (!String.IsNullOrEmpty(srli[y]) && modsstr.Contains(srli[y]))
                                {
                                    Logging.Log("[REDEF] > Contains the modifier: " + srli[y]);
                                    redy = false;
                                    break;
                                }
                            }
                        }
                        if (redy)
                        {
                            KMHook.KeybdEvent(redefines[i].v, (wParam.ToInt32() == WinAPI.WM_KEYDOWN || wParam.ToInt32() == WinAPI.WM_SYSKEYDOWN) ? 0 : 2);
                            return((IntPtr)1);
                        }
                        else
                        {
                            Logging.Log("[REDEF] > Redefine cancelled: by mods: " + redefines_excl_mods[i] + " (" + modsstr + ")");
                        }
                    }
                }
            }
            #endregion
            #region Mahou.mm Tray Hotkeys
            var x = new Tuple <bool, bool, bool, bool, bool, bool, bool, Tuple <bool, int> >(alt, alt_r, shift, shift_r, ctrl, ctrl_r, win, new Tuple <bool, int>(win_r, vk));
//				Debug.WriteLine("x_hk: " + Hotkey.tray_hk_to_string(x));
//				Debug.WriteLine("dhk_wait: " +dhk_tray_wait);
//				Debug.WriteLine("dhk_hk: " +dhk_tray_hk);
            if (dhk_tray_wait)
            {
                var hk       = Hotkey.tray_hk_parse(dhk_tray_hk);
                var UpOrDown = OnUpOrDown((Keys)hk.Rest.Item2, wParam);
                if (UpOrDown)
                {
                    var eq = Hotkey.cmp_hotkey(hk, x);
                    //				Debug.WriteLine("dhk_eq: "+eq);
                    if (eq)
                    {
                        Logging.Log("[TR_HK] > Executing action of (double)hotkey: " + dhk_tray_hk_real + " on second hotkey: " + dhk_tray_hk);
                        KMHook.DoSelf(dhk_tray_act, "tray_hotkeys_double");
                        dhk_unset();
                        KMHook.SendModsUp(15, false);                         // less overkill when whole hotkey is being hold
                        return((IntPtr)1);
                    }
                }
            }
            else
            {
                for (int i = 0; i != MahouUI.tray_hotkeys.len; i++)
                {
                    var hk       = Hotkey.tray_hk_parse(MahouUI.tray_hotkeys[i].k);
                    var UpOrDown = OnUpOrDown((Keys)hk.Rest.Item2, wParam);
//					Debug.WriteLine((UpOrDown ? "UP":"DOWN") + " key: " +Key);
                    if (UpOrDown)
                    {
                        if (Hotkey.cmp_hotkey(hk, x))
                        {
                            var d = Hotkey.tray_hk_is_double(MahouUI.tray_hotkeys[i].k);
                            if (d.Item1)
                            {
                                dhk_tray_wait    = true;
                                dhk_tray_hk      = d.Item3;
                                dhk_tray_act     = MahouUI.tray_hotkeys[i].v.Item1;
                                dhk_tray_hk_real = MahouUI.tray_hotkeys[i].k;
                                if (dhk_timer != null)
                                {
                                    dhk_timer.Stop();
                                    dhk_timer.Dispose();
                                }
                                dhk_timer          = new Timer();
                                dhk_timer.Interval = d.Item2;
                                dhk_timer.Tick    += (_, __) => { Debug.WriteLine("Unset timer dhk! " + dhk_timer.Interval + "ms"); dhk_unset(); dhk_timer.Stop(); dhk_timer.Dispose(); };
                                dhk_timer.Start();
                            }
                            else
                            {
                                Logging.Log("[TR_HK] > Executing action of hotkey: " + MahouUI.tray_hotkeys[i].k);
                                dhk_unset();
                                if (MahouUI.tray_hotkeys[i].v.Item2.Contains("hk|c") || MahouUI.tray_hotkeys[i].v.Item2.Contains("hk|s"))
                                {
                                    var altl = ((hk.Item1 || hk.Rest.Item2 == (int)Keys.LMenu) && !hk.Item2 &&                                     // l alt not r alt
                                                !hk.Item3 && !hk.Item4 &&
                                                !hk.Item5 && !hk.Item6 &&
                                                !hk.Item7 && !hk.Rest.Item1);
                                    var altr = (!hk.Item1 && (hk.Item2 || hk.Rest.Item2 == (int)Keys.RMenu) &&
                                                !hk.Item3 && !hk.Item4 &&
                                                !hk.Item5 && !hk.Item6 &&
                                                !hk.Item7 && !hk.Rest.Item1);
                                    if (altl || altr)
                                    {
                                        if (Locales.ActiveWindowClassName(40).Contains("Chrome_WidgetWin"))
                                        {
                                            MahouUI.chrome_window_alt_fix();
                                        }
                                    }
                                    else
                                    {
                                        KMHook.SendModsUp(15, false);                                         // less overkill when whole hotkey is being hold
                                    }
                                    if (altl)
                                    {
                                        KMHook.KeybdEvent(Keys.LMenu, 0);
                                        KMHook.KeybdEvent(Keys.LMenu, 2);
                                    }
                                    if (altr)
                                    {
                                        KMHook.KeybdEvent(Keys.RMenu, 0);
                                        KMHook.KeybdEvent(Keys.RMenu, 2);
                                    }
                                    if ((!hk.Item1 && !hk.Item2 &&
                                         !hk.Item3 && !hk.Item4 &&
                                         !hk.Item5 && !hk.Item6 &&
                                         (hk.Item7 || hk.Rest.Item2 == (int)Keys.LWin) && !hk.Rest.Item1))
                                    {
                                        KMHook.KeybdEvent(Keys.LWin, 0);
                                        KMHook.KeybdEvent(Keys.LWin, 2);
                                    }
                                    if ((!hk.Item1 && !hk.Item2 &&
                                         !hk.Item3 && !hk.Item4 &&
                                         !hk.Item5 && !hk.Item6 &&
                                         !hk.Item7 && (hk.Rest.Item1 || hk.Rest.Item2 == (int)Keys.RWin)))
                                    {
                                        KMHook.KeybdEvent(Keys.RWin, 0);
                                        KMHook.KeybdEvent(Keys.RWin, 2);
                                    }
                                }
                                KMHook.DoSelf(MahouUI.tray_hotkeys[i].v.Item1, "tray_hotkeys");
                                return((IntPtr)1);
                            }
                        }
                    }
                }
            }
            #endregion
            if (MahouUI.SnippetsEnabled)
            {
                if (KMHook.c_snip.Count > 0)
                {
                    var t = MMain.mahou.SnippetsExpandType == "Tab";
                    if (t && Key == Keys.Tab && !shift && !alt && !win && !ctrl && !shift_r && !alt_r && !ctrl_r && !win_r)
                    {
                        WinAPI.keybd_event((byte)Keys.F14, (byte)Keys.F14, 0, 0);
                        return((IntPtr)1);                        // Disable event
                    }
                    if (!t && MMain.mahou.SnippetsExpandType != "Space" && wParam == (IntPtr)WinAPI.WM_KEYDOWN || wParam == (IntPtr)WinAPI.WM_SYSKEYDOWN)
                    {
                        var ms = KMHook.GetModsStr(ctrl, ctrl_r, shift, shift_r, alt, alt_r, win, win_r);
                        ms += Key;
                        var othmatch = ms == MMain.mahou.SnippetsExpKeyOther;
                        Debug.WriteLine("Checking SnippetsExpOther: [" + ms + "] == [" + MMain.mahou.SnippetsExpKeyOther + "] => " + othmatch);
                        if (othmatch)
                        {
                            KMHook.ClearModifiers();
                            WinAPI.keybd_event((byte)Keys.F20, (byte)Keys.F20, 0, 0);
                            return((IntPtr)1);
                        }
                    }
                }
            }
            if (MahouUI.RemapCapslockAsF18)
            {
                bool _shift = !shift, _alt = !alt, _ctrl = !ctrl, _win = !win, _shift_r = !shift_r, _alt_r = !alt_r, _ctrl_r = !ctrl_r, _win_r = !win_r;
                if (Key == Keys.CapsLock)
                {
                    for (int i = 1; i != 5; i++)
                    {
                        var KeyIndex = (int)typeof(MahouUI).GetField("Key" + i).GetValue(MMain.mahou);
                        if (KeyIndex == 8)                           // Shift+CapsLock
                        {
                            _shift   = shift;
                            _shift_r = shift_r;
                        }
                    }
                }
                uint mods = 0;
                if (alt || alt_r)
                {
                    mods += WinAPI.MOD_ALT;
                }
                if (ctrl || ctrl_r)
                {
                    mods += WinAPI.MOD_CONTROL;
                }
                if (shift || shift_r)
                {
                    mods += WinAPI.MOD_SHIFT;
                }
                if (win || win_r)
                {
                    mods += WinAPI.MOD_WIN;
                }
                bool has = MMain.mahou.HasHotkey(new Hotkey(false, (uint)Keys.F18, mods, 77));
                if (has)
                {
                    if (Hotkey.ContainsModifier((int)mods, (int)WinAPI.MOD_SHIFT))
                    {
                        _shift = shift;
                    }
                    _shift_r = shift_r;
                    if (Hotkey.ContainsModifier((int)mods, (int)WinAPI.MOD_ALT))
                    {
                        _alt = alt;
                    }
                    _alt_r = alt_r;
                    if (Hotkey.ContainsModifier((int)mods, (int)WinAPI.MOD_CONTROL))
                    {
                        _ctrl = ctrl;
                    }
                    _ctrl_r = ctrl_r;
                    if (Hotkey.ContainsModifier((int)mods, (int)WinAPI.MOD_WIN))
                    {
                        _win = win;
                    }
                    _win_r = win_r;
                }
                var GJIME = false;
                if (vk >= 240 && vk <= 242)                 // GJ IME's Shift/Alt/Ctrl + CapsLock
                {
                    GJIME = true;
                }
                //			Debug.WriteLine(Key + " " +has + "// " + _shift + " " + _alt + " " + _ctrl + " " + _win + " " + mods + " >> " + (Key == Keys.CapsLock && _shift && _alt && _ctrl && _win));
                if ((Key == Keys.CapsLock || GJIME) && _shift && _alt && _ctrl && _win && _shift_r && _alt_r && _ctrl_r && _win_r)
                {
                    var flags = (int)(KInputs.IsExtended(Key) ? WinAPI.KEYEVENTF_EXTENDEDKEY : 0);
                    if (wParam == (IntPtr)WinAPI.WM_KEYUP)
                    {
                        flags |= (int)WinAPI.KEYEVENTF_KEYUP;
                    }
                    WinAPI.keybd_event((byte)Keys.F18, (byte)Keys.F18, flags, 0);
                    return((IntPtr)1);                    // Disable event
                }
                //			Debug.WriteLine(Marshal.GetLastWin32Error());
            }
            return(WinAPI.CallNextHookEx(_LLHook_ID, nCode, wParam, lParam));
        }
예제 #4
0
파일: LLHook.cs 프로젝트: Makishima/Mahou
        public static IntPtr Callback(int nCode, IntPtr wParam, IntPtr lParam)
        {
            if (MMain.mahou == null || nCode < 0)
            {
                return(WinAPI.CallNextHookEx(_LLHook_ID, nCode, wParam, lParam));
            }
            if (KMHook.ExcludedProgram() && !MahouUI.ChangeLayoutInExcluded)
            {
                return(WinAPI.CallNextHookEx(_LLHook_ID, nCode, wParam, lParam));
            }
            var vk  = Marshal.ReadInt32(lParam);
            var Key = (Keys)vk;

            if (MahouUI.BlockAltUpNOW)
            {
                if ((wParam == (IntPtr)WinAPI.WM_SYSKEYUP || wParam == (IntPtr)WinAPI.WM_KEYUP) &&
                    (Key == Keys.LMenu || Key == Keys.RMenu || Key == Keys.Menu))
                {
                    Debug.WriteLine("ihihihihihihihih-hihih-hi blocked alt :)))))");
                    MahouUI.BlockAltUpNOW = false;
                    return((IntPtr)1);
                }
            }
            SetModifs(Key, wParam);
            Debug.WriteLine("Alive" + vk);
            #region Mahou.mm Tray Hotkeys
            if (wParam == (IntPtr)WinAPI.WM_KEYDOWN || wParam == (IntPtr)WinAPI.WM_SYSKEYDOWN)
            {
                for (int i = 0; i != MahouUI.tray_hotkeys.len; i++)
                {
                    var x = new Tuple <bool, bool, bool, bool, bool, bool, bool, Tuple <bool, int> >(alt, alt_r, shift, shift_r, ctrl, ctrl_r, win, new Tuple <bool, int>(win_r, vk));
                    if (Hotkey.cmp_hotkey(Hotkey.tray_hk_parse(MahouUI.tray_hotkeys[i].k), x))
                    {
                        Logging.Log("[TR_HK] > Executing action of hotkey: " + MahouUI.tray_hotkeys[i].k);
                        KMHook.DoSelf(MahouUI.tray_hotkeys[i].v, "tray_hotkeys");
                        KMHook.SendModsUp(15, false);                         // less overkill when whole hotkey is being hold
                        return((IntPtr)1);
                    }
                }
            }
            #endregion
            if (MahouUI.SnippetsEnabled)
            {
                if (KMHook.c_snip.Count > 0)
                {
                    if (MMain.mahou.SnippetsExpandType == "Tab" && Key == Keys.Tab && !shift && !alt && !win && !ctrl && !shift_r && !alt_r && !ctrl_r && !win_r)
                    {
                        WinAPI.keybd_event((byte)Keys.F14, (byte)Keys.F14, (int)WinAPI.KEYEVENTF_KEYUP, 0);
                        return((IntPtr)1);                        // Disable event
                    }
                }
            }
            if (MahouUI.RemapCapslockAsF18)
            {
                bool _shift = !shift, _alt = !alt, _ctrl = !ctrl, _win = !win, _shift_r = !shift_r, _alt_r = !alt_r, _ctrl_r = !ctrl_r, _win_r = !win_r;
                if (Key == Keys.CapsLock)
                {
                    for (int i = 1; i != 5; i++)
                    {
                        var KeyIndex = (int)typeof(MahouUI).GetField("Key" + i).GetValue(MMain.mahou);
                        if (KeyIndex == 8)                         // Shift+CapsLock
                        {
                            _shift = shift;
                        }
                        _shift_r = shift_r;
                    }
                }
                uint mods = 0;
                if (alt || alt_r)
                {
                    mods += WinAPI.MOD_ALT;
                }
                if (ctrl || ctrl_r)
                {
                    mods += WinAPI.MOD_CONTROL;
                }
                if (shift || shift_r)
                {
                    mods += WinAPI.MOD_SHIFT;
                }
                if (win || win_r)
                {
                    mods += WinAPI.MOD_WIN;
                }
                bool has = MMain.mahou.HasHotkey(new Hotkey(false, (uint)Keys.F18, mods, 77));
                if (has)
                {
                    if (Hotkey.ContainsModifier((int)mods, (int)WinAPI.MOD_SHIFT))
                    {
                        _shift = shift;
                    }
                    _shift_r = shift_r;
                    if (Hotkey.ContainsModifier((int)mods, (int)WinAPI.MOD_ALT))
                    {
                        _alt = alt;
                    }
                    _alt_r = alt_r;
                    if (Hotkey.ContainsModifier((int)mods, (int)WinAPI.MOD_CONTROL))
                    {
                        _ctrl = ctrl;
                    }
                    _ctrl_r = ctrl_r;
                    if (Hotkey.ContainsModifier((int)mods, (int)WinAPI.MOD_WIN))
                    {
                        _win = win;
                    }
                    _win_r = win_r;
                }
                var GJIME = false;
                if (vk >= 240 && vk <= 242)                 // GJ IME's Shift/Alt/Ctrl + CapsLock
                {
                    GJIME = true;
                }
                //			Debug.WriteLine(Key + " " +has + "// " + _shift + " " + _alt + " " + _ctrl + " " + _win + " " + mods + " >> " + (Key == Keys.CapsLock && _shift && _alt && _ctrl && _win));
                if ((Key == Keys.CapsLock || GJIME) && _shift && _alt && _ctrl && _win && _shift_r && _alt_r && _ctrl_r && _win_r)
                {
                    var flags = (int)(KInputs.IsExtended(Key) ? WinAPI.KEYEVENTF_EXTENDEDKEY : 0);
                    if (wParam == (IntPtr)WinAPI.WM_KEYUP)
                    {
                        flags |= (int)WinAPI.KEYEVENTF_KEYUP;
                    }
                    WinAPI.keybd_event((byte)Keys.F18, (byte)Keys.F18, flags, 0);
                    return((IntPtr)1);                    // Disable event
                }
                //			Debug.WriteLine(Marshal.GetLastWin32Error());
            }
            return(WinAPI.CallNextHookEx(_LLHook_ID, nCode, wParam, lParam));
        }