Questions tagged [setwindowshookex]

Use this tag to better reference questions related to SetWindowsHookEx. This function installs an application-defined hook procedure into a hook chain.

Installs an application-defined hook procedure into a hook chain. You would install a hook procedure to monitor the system for certain types of events. These events are associated either with a specific thread or with all threads in the same desktop as the calling thread.

C# Syntax

HHOOK WINAPI SetWindowsHookEx(
  _In_ int       idHook,
  _In_ HOOKPROC  lpfn,
  _In_ HINSTANCE hMod,
  _In_ DWORD     dwThreadId
);

To find more informatoin :

241 questions
25
votes
7 answers

What can cause Windows to unhook a low level (global) keyboard hook?

We have some global keyboard hooks installed via SetWindowsHookEx with WH_KEYBOARD_LL that appear to randomly get unhooked by Windows. We verified that they hook was no longer attached because calling UnhookWindowsHookEx on the handle returns…
Davy8
  • 30,868
  • 25
  • 115
  • 173
21
votes
1 answer

SetWindowsHookEx fails with error 126

I'm trying to use the Gma.UserActivityMonitor library in a project and I've faced an error I can not overcome on my own. In the HookManager.Callbacks.cs file there's a static method called EnsureSubscribedToGlobalMouseEvents with the following code…
Mehran
  • 15,593
  • 27
  • 122
  • 221
13
votes
3 answers

SetWindowsHookEx failing in .NET 4.0 on 32-bit machine with "module not found"?

I have found similar questions on this page, but I can't seem to figure out how to interpret the answers or figure out if they are truly duplicates. Here are the possible duplicates I've found, with comments: SetWindowsHookEx returns 0 when…
Lasse V. Karlsen
  • 380,855
  • 102
  • 628
  • 825
11
votes
5 answers

Is it possible to detect when a low-level keyboard hook has been automatically disconnected by Windows?

I am working on a program that uses keyboard hooks. However, when the PC that the program is running on is just slightly overloaded, it causes Windows to disconnect the hook from the program, causing it to no longer respond to keystrokes. Is there a…
Mathias Lykkegaard Lorenzen
  • 15,031
  • 23
  • 100
  • 187
11
votes
4 answers

SetWindowsHookEx returns 0 when compiling for the .NET 4.0 framework in 32bit machines

I'm trying to set a low level windows keyboard hook to grab three keys pressed even if the application is not in focus. To do this I'm calling SetWindowsHookEx as // Create an instance of HookProc. KeyboardHookProcedure = new…
eblacklight
  • 183
  • 1
  • 1
  • 7
11
votes
1 answer

Is it possible to remove touch messages (WM_POINTERDOWN etc.) that an application receives?

I have successfully installed a WH_GETMESSAGE hook with SetWindowsHookEx and I can see the WM_POINTERDOWN, WM_POINTERUP etc. messages that the application receives. (It is a 32 bit desktop application running on Windows 8.1.) Now, I not only want to…
wmeyer
  • 3,426
  • 1
  • 18
  • 26
11
votes
7 answers

SetWindowsHookEx in C#

I'm trying to hook a 3rd party app so that I can draw to its screen. Drawing to the screen is easy, and I need no help with it, but I seem to be having issues with using SetWindowsHookEx to handle WH_GETMESSAGE. I can't figure out what to pass for…
Darthg8r
  • 12,377
  • 15
  • 63
  • 100
10
votes
2 answers

SetWindowsHookEx creates a local hook. How to make it global?

In a Delphi XE application I am trying to set up a global hook to monitor focus changes. The hook is created in a dll: focusHook := SetWindowsHookEx( WH_CBT, @FocusHookProc, HInstance, 0 ); // dwThreadId (the last argument) set to 0 should create a…
Marek Jedliński
  • 7,088
  • 11
  • 47
  • 57
10
votes
2 answers

How to hook Win + Tab using LowLevelKeyboardHook

In a few words: blocking Win up after Win + Tab makes Windows think Win is still down, so then pressing S with the Win key up for example will open the search charm rather than just type "s"... until the user presses Win again. Not blocking it means…
8
votes
1 answer

SetWindowsHookEx for WH_JOURNALRECORD fails under Vista/Windows 7

I am preparing a Delphi module, which sets a hook in a thread to record a macro: FHandleRec := SetWindowsHookEx(WH_JOURNALRECORD, FRecordProc, HInstance, 0); FHandlePlay := SetWindowsHookEx(WH_JOURNALPLAYBACK, FPlayProc, HInstance, 0); That works…
8
votes
1 answer

Keyboard hook to look for F12 with delphi

This question may have already been answered but I've been unable to find the proper response. I'm trying to turn toggle a debug switch when the F12 key is pressed in a form. I'm unable to use the onkeydown event since I would have to setup a…
Rich R
  • 367
  • 4
  • 15
7
votes
1 answer

Click Tracking Windows Applications

I'm interesting in gathering usage metrics for an application that I did not write and have no control over. This is a applicaiton running on Windows. My plan for this is to register a global windows hook for mouse and keyboards events, and record…
RMD
  • 3,421
  • 7
  • 39
  • 85
7
votes
4 answers

Win32 Hooks DLL injection into Applications Built against "Any CPU"

I am working on a project which captures all User Interactions. MSDN tells (this) SetWindowsHookEx can be used to inject a DLL into another process. A 32-bit DLL cannot be injected into a 64-bit process, and a 64-bit DLL cannot be injected…
sri
  • 1,005
  • 1
  • 12
  • 26
7
votes
3 answers

Why would Windows hooks not receive certain messages?

Microsoft does not recommend DirectInput for keyboard and mouse input. As such, I've written an input manager class that uses SetWindowsHookEx to hook into WndProc and GetMsg. I believe the hooks are set appropriately, though they look to be the…
Sion Sheevok
  • 4,057
  • 2
  • 21
  • 37
7
votes
0 answers

How to pass arguments to SetWindowsHookEx's callback? (if even possible)

I'm using SetWindowsHookEx with WH_CALLWNDPROC to catch all WndProc messages - and it works fine. I was wondering if there is a way to store a parameter somewhere where the callback function can read and use it. I assume that because the callback…
talbenmoshe
  • 101
  • 4
1
2 3
16 17