Questions tagged [mouse-hook]

Changing, listening or reacting to events related to specific mouse events.

A mouse hook is a feature that allows to replace or extend the standard behavior for specific mouse events in a systematic way.

The hook may work at a low level, by replacing some system routines at operating system level or at driver level. It is different from a simple event listener, in that the hooks behavior is not specific for a software feature, but is general to the whole application or event to the whole system.

Related tags

  • Use tag for hooking other event drivers than those of the mouse.
  • Use age for hooking mouse keys and keyboard keys
  • Use tag for .Net mouse key hooking

See also

92 questions
3
votes
2 answers

How can I set cursor position from mouse hook in Windows?

I'm trying to create a little app that will detect when the mouse cursor moves to the edge of the screen and will move it to the opposite edge, to create a continuous desktop effect, if that makes sense. Below is some code from someone else (the…
Steve Whitfield
  • 1,981
  • 3
  • 21
  • 30
3
votes
1 answer

Cast IntPtr to CWPSTRUCT

In my c# project I’m trying to intercept mouse clicks from another program, but only the ones that come from a certain hwnd as well… I’ve read here that I can filter my messages using the lParam but I’ve not succeeded to cast it to something I can…
VincentC
  • 245
  • 4
  • 14
2
votes
2 answers

Is there a .NET library for sending keystrokes, mouse clicks, mouse movements and other input? Similar to AutoHotKey but for .NET library use?

I'm looking to essentially write code similar to what I can do with AutoHotKey, only in .NET and C#, because it's a much more robust environment. I didn't know if there was a wrapper library available for these sorts of hooks or not. Does anyone…
Ben Lesh
  • 107,825
  • 47
  • 247
  • 232
2
votes
0 answers

Globally Detecting Key Presses and Mouse Clicks

I am attempting to create a program to globally detect key presses and mouse clicks. I have googled around and found solutions for both and got them working in the same program. But I would like to combine the two separate classes into one class…
Nullone
  • 107
  • 1
  • 1
  • 6
2
votes
1 answer

Low level mouse hook doesn't fire mousedown/mouseup event on admin process

I'm now editing this item since I think I have pinpointed the issue, this seems to be an OS bug for Win8.1 and Win10. Issue summary is still same as before "Low level mouse hook doesn't fire mousedown/mouseup event on admin process"... for admin…
Code.Blodded
  • 231
  • 1
  • 19
2
votes
0 answers

How to intercept mouse and keyboard events and send custom ones in C++?

Alright, I want to write a program that intercepts mouse and keyboard events before they are reported to the active window/application, whatever that may be. Based on my program logic I want to be able to send custom key events. For example: When…
jsonnull
  • 415
  • 3
  • 12
2
votes
2 answers

Obtain mouse click position relative to active window

Having worked out how to obtain the mouse click position anywhere along the monitor boundaries using low level hooks I receive an X Y coordinate that will contain a value typically between x: -1680 to +1920 and y: 0 to 1200 in my pcs case. Easy…
Maxim Gershkovich
  • 45,951
  • 44
  • 147
  • 243
2
votes
1 answer

Is there a low overhead way to hook a mouse doubleclick using Delphi?

Here's what I would like to do in Delphi XE: Capture a double-click in another application such that when it occurs and the text underneath the mouse is highlighted, this triggers a series of events in my application based on what the text…
b-p
  • 307
  • 3
  • 10
1
vote
1 answer

How to prevent mouse from turning on monitor?

The following code is able to lock mouse events successfully. This was my attempt to prevent the mouse from turning on the monitor when it is off, but the monitor always turns on when executing any action with the mouse, ex: left button click. Is…
FLASHCODER
  • 1
  • 7
  • 24
1
vote
1 answer

What is the end of the road for a WM_LBUTTONUP or WM_LBUTTONDOWN in a low level procedure hook?

I'm writing a low level mouse hook in Windows using the Win32 API, I want to intercept either a button being pressed down or up (still undecided) depending on certain conditions. To position ourselves let's consider the following snipped of a…
James Russell
  • 339
  • 1
  • 3
  • 12
1
vote
0 answers

SendInput() causes infinite loop when used with GetAsyncKeyState() (WinAPI)

So I want to make when you hold down your left click, the mouse starts to click at regular intervals. In theory all should work right, but in practice, not so well. Anyways here is the code I am using for the detection and clicking of the…
xXTurner
  • 61
  • 9
1
vote
1 answer

Is it possible to capture coordinates of mouse clicked on another application e.g calculator and later force a click using code (C#)?

I am developing an application using Windows Form (C#). I need to be able to press a button which starts monitoring the location of the next mouse-click inside another application. The coordinates of this click then need to be used to force a click…
Azhar Ali
  • 23
  • 3
1
vote
0 answers

How to know Element information using UIAutomation Element in Windows API Mouse Hook

In my program, when i hover my mouse, i want to know some information about the element, so far i am able to get the name of the element. But i also want to know its localized control type Automation…
1
vote
1 answer

Setting process DPI awareness so that the system compensates for scaling factors

I have the following mouse hook procedure (simplified for the explanation). SetWindowsHookEx(WH_MOUSE_LL, mouseHookProc, GetModuleHandle(NULL), 0) ; LRESULT mouseHookProc(int code, WPARAM wParam, LPARAM lParam){ if(code==HC_ACTION){ …
1
vote
0 answers

com.sun.jna.Native$1 uncaughtException

Recently,I try to get information of mouse by jna because my project need this function.The.But there is a exception occur when I run the following code.I have google ,but there is nothing about problem.I'm confused,please help me ~~ import…
Tony.Xu
  • 11
  • 2