keyboard-hook

Word Addin Local Keyboard Hook

旧时模样 提交于 2019-12-11 12:24:39
问题 I'm trying to create a MS Word addin with an auto-correct feature. The code block below is taken from here. However it catches all the key events from any application. I know this is normal because in this line: SetWindowsHookEx(WH_KEYBOARD_LL, procedure, GetModuleHandle(module.ModuleName), 0); the last parameter is the thread id and when it is equal to 0 which means a global hook. But when I try to change it to: SetWindowsHookEx(WH_KEYBOARD_LL, procedure, GetModuleHandle(module.ModuleName),

global keyboard hook slowing down computer

一世执手 提交于 2019-12-11 12:06:05
问题 I am using the code from this article : private const int WH_KEYBOARD_LL = 13; private const int WM_KEYDOWN = 0x0100; private static LowLevelKeyboardProc _proc = HookCallback; private static IntPtr _hookID = IntPtr.Zero; public static void Main() { _hookID = SetHook(_proc); //Application.Run(); //UnhookWindowsHookEx(_hookID); } private static IntPtr SetHook(LowLevelKeyboardProc proc) { using (Process curProcess = Process.GetCurrentProcess()) using (ProcessModule curModule = curProcess

Differentiate between two keyboards in a KeyboardHook

点点圈 提交于 2019-12-11 09:37:48
问题 I got this program: http://blogs.msdn.com/b/toub/archive/2006/05/03/589423.aspx using System; using System.Diagnostics; using System.Windows.Forms; using System.Runtime.InteropServices; namespace KeyboardInput { class InterceptKeys { private delegate IntPtr LowLevelKeyboardProc(int nCode, IntPtr wParam, IntPtr lParam); private const int WH_KEYBOARD_LL = 13; private const int WM_KEYDOWN = 0x0100; private static LowLevelKeyboardProc _proc = HookCallback; private static IntPtr _hookID = IntPtr

WinForms: How to prevent textbox from handling alt key and losing focus?

Deadly 提交于 2019-12-11 03:38:13
问题 I have this textbox I use to capture keyboard shortcuts for a preferences config. I use a low-level keyboard hook to capture keys and also prevent them from taking action, e.g. the Windows key, but the Alt key still comes through and makes my textbox lose focus. How can I block the Alt key, so the focus is kept unaltered at my textbox? 回答1: private void textBox1_KeyDown(object sender, KeyEventArgs e) { if (e.Alt) { e.Handled = true; } } 回答2: You can register for the keydown event and for the

C# Global keyboard hook in Office Addin 2013

你。 提交于 2019-12-11 03:22:47
问题 I encounter a problem to make my Office Addin works with my global keyboard on Powerpoint 2013 but not on the previous versions (2007 and 2010). I do not get any exception but it seems that the OnKeyDown event is never triggered on Powerpoint 2013, and I don't know why. I get the same problems on all versions of Windows (XP, 7, 8 & 8.1), on 32 & 64 bits environments. The version of Microsoft Office is 32 bits. Here is a code sample : using System; using System.Collections.Generic; using

Low level keyboard Hook not at UI thread

血红的双手。 提交于 2019-12-11 02:21:41
问题 I want to create a good library for keyboard hook. I use a method SetWindowsHookEx and I have noticed that method hookProc, which should be called at any system KeyDown event, is not executed if the main thread of my app is bussy. I think the hook shold be made so, that the other thread would be responsible for it. Is that possible? How can I do it? 回答1: Microsoft help page of LowLevelKeyboardProc mentions that If the hook procedure times out, the system passes the message to the next hook.

SetWindowsHookEx does not react on media keys

微笑、不失礼 提交于 2019-12-11 02:15:10
问题 I want to capture user keyboard input to react well on keyboard media keys: play/pause, next and previous in particular. I tried to use SetWindowsHookEx with low-level WH_KEYBOARD_LL param to ensure I can get maximum responsibility from this WINAPI function, and I stucked with nothing. If I set breakpoint in hook callback, debugger stops on any keyboard event when I hit regular keys, such as letters or F modifiers, but it never stops when I hit one of media keys, such as Play/Payse. I tried

Global Keyboard hook not working

强颜欢笑 提交于 2019-12-11 02:08:48
问题 I have created a global Keyboard hook. Hook is created in a DLL. #pragma comment(linker, "/SECTION:.SHARED,RWS") #pragma data_seg(".SHARED") static HHOOK hkb=NULL; static CMyFile *pLF; #pragma data_seg() HINSTANCE hins = NULL; extern "C" LRESULT __declspec(dllexport) __stdcall CALLBACK KeyBoardHookProc( int nCode, WPARAM wParam, LPARAM lParam) { if (nCode < 0) { return CallNextHookEx(0, nCode, wParam, lParam); } return CallNextHookEx(hkb, nCode, wParam, lParam); } extern "C" LRESULT _

key capture using global hotkey in C#

﹥>﹥吖頭↗ 提交于 2019-12-10 15:15:31
问题 I have a application that runs in the background like i may keep my app in the system tray.If it remains on system tray my app will do it's job. Whenever a user press F10 or F9 some works will be done. i tried this: public partial class Form1 : Form { public int a = 1; [DllImport("user32.dll")] public static extern bool RegisterHotKey(IntPtr hWnd, int id, int fsModifiers, int vlc); [DllImport("user32.dll")] public static extern bool UnregisterHotKey(IntPtr hWnd, int id); [DllImport("User32

How to receive keyboard input from application with admin privileges to a non-admin application?

你说的曾经没有我的故事 提交于 2019-12-10 12:36:16
问题 I have programmed an application that has an overlay-kind of window that can be shown and hidden via hotkey while another application has the focus. Said other application is a DirectX game that runs with admin privileges. I have already tried 3 possible solutions to get notified when my hotkey is pressed in the other application, 2 of them kind of work, but require my application to have administrative privileges too. That is kind of acceptable, but I'd much rather have a solution that does