鼠标钩子结构体MOUSEHOOKSTRUCT(EX)

Syntax

MOUSEHOOKSTRUCT (winuser.h) | Microsoft Docs https://docs.microsoft.com/en-us/windows/desktop/api/winuser/ns-winuser-mousehookstruct

typedef struct tagMOUSEHOOKSTRUCT {
  POINT     pt;
  HWND      hwnd;
  UINT      wHitTestCode;
  ULONG_PTR dwExtraInfo;
} MOUSEHOOKSTRUCT, *LPMOUSEHOOKSTRUCT, *PMOUSEHOOKSTRUCT;

Members成员

pt :
Specifies a POINT structure that contains the x- and y-coordinates of the cursor, in screen coordinates. 指定在屏幕坐标系下,包含有光标x、y坐标的POINT结构。

>hwnd : wHitTestCode :Specifies the hit-test value. For a list of hit-test values, see the description of the WM_NCHITTEST message. 指定点击测试值。查看WM_NCHITTEST消息可以得到值的列表。

dwExtraInfo :Specifies extra information associated with the message. 指定和该消息相关联的附加信息。

MOUSEHOOKSTRUCTEX Structure

The MOUSEHOOKSTRUCTEX structure contains information about a mouse event passed to a WH_MOUSE hook procedure, MouseProc.

MOUSEHOOKSTRUCTEX结构包含有传递给WH_MOUSE钩子子程MouseProc的关于鼠标事件的信息。

This is an extension of the MOUSEHOOKSTRUCT structure that includes information about wheel movement or the use of the X button.

这是对MOUSEHOOKSTRUCT的扩展。包含有滚轮的活动和X键的使用。

SetWindowsHookExA function (winuser.h) | Microsoft Docs https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-setwindowshookexa
Syntax

HHOOK SetWindowsHookExA(
  int       idHook,
  HOOKPROC  lpfn,
  HINSTANCE hmod,
  DWORD     dwThreadId
);

Members成员

MOUSEHOOKSTRUCT

The members of a MOUSEHOOKSTRUCT structure make up the first part of this structure.

MOUSEHOOKSTRUCT结构的成员构成了该结构的前面部分。

mouseData

If the message is WM_MOUSEWHEEL, the HIWORD of this member is the wheel delta. The LOWORD is undefined and reserved. A positive value indicates that the wheel was rotated forward, away from the user; a negative value indicates that the wheel was rotated backward, toward the user. One wheel click is defined as WHEEL_DELTA, which is 120.

如果消息是WM_MOUSEWHEEL,该成员的HIWORD就是wheel delta。LOWORD做为保留未定义。正值表示滚轮向前旋转,即远离用户的方向;负值表示滚轮向后旋转,即朝向用户的方向。滚轮的点击被定义为WHEEL_DELTA,具体值为120。

If the message is WM_XBUTTONDOWN, WM_XBUTTONUP, WM_XBUTTONDBLCLK, WM_NCXBUTTONDOWN, WM_NCXBUTTONUP, or WM_NCXBUTTONDBLCLK, the HIWORD of mouseData specifies which X button was pressed or released, and the LOWORD is undefined and reserved. This member can be one or more of the following values. Otherwise,mouseData is not used.

如果消息是WM_XBUTTONDOWN, WM_XBUTTONUP, WM_XBUTTONDBLCLK, WM_NCXBUTTONDOWN, WM_NCXBUTTONUP, 或者WM_NCXBUTTONDBLCLK, mouseData 的HIWORD值指定哪个X键被按下或者释放,LOWORD做为保留未定义。该成员可以是以下值中的一个或者多个。否则,mouseData未使用。

1.XBUTTON1 :The first X button was pressed or released. 第一个X键被按下或者释放。

2.XBUTTON2 :The second X button was pressed or released.第二个X键被按下或者释放。

Parameters
idHook

Type: int

The type of hook procedure to be installed. This parameter can be one of the following values.

Value Meaning
WH_CALLWNDPROC
4
Installs a hook procedure that monitors messages before the system sends them to the destination window procedure. For more information, see the CallWndProc hook procedure.
WH_CALLWNDPROCRET
12
Installs a hook procedure that monitors messages after they have been processed by the destination window procedure. For more information, see the CallWndRetProc hook procedure.
WH_CBT
5
Installs a hook procedure that receives notifications useful to a CBT application. For more information, see the CBTProc hook procedure.
WH_DEBUG
9
Installs a hook procedure useful for debugging other hook procedures. For more information, see the DebugProc hook procedure.
WH_FOREGROUNDIDLE
11
Installs a hook procedure that will be called when the application's foreground thread is about to become idle. This hook is useful for performing low priority tasks during idle time. For more information, see the ForegroundIdleProc hook procedure.
WH_GETMESSAGE
3
Installs a hook procedure that monitors messages posted to a message queue. For more information, see the GetMsgProc hook procedure.
WH_JOURNALPLAYBACK
1
Installs a hook procedure that posts messages previously recorded by a WH_JOURNALRECORD hook procedure. For more information, see the JournalPlaybackProc hook procedure.
WH_JOURNALRECORD
0
Installs a hook procedure that records input messages posted to the system message queue. This hook is useful for recording macros. For more information, see the JournalRecordProc hook procedure.
WH_KEYBOARD
2
Installs a hook procedure that monitors keystroke messages. For more information, see the KeyboardProc hook procedure.
WH_KEYBOARD_LL
13
Installs a hook procedure that monitors low-level keyboard input events. For more information, see the LowLevelKeyboardProc hook procedure.
WH_MOUSE
7
Installs a hook procedure that monitors mouse messages. For more information, see the MouseProc hook procedure.
WH_MOUSE_LL
14
Installs a hook procedure that monitors low-level mouse input events. For more information, see the LowLevelMouseProc hook procedure.
WH_MSGFILTER
-1
Installs a hook procedure that monitors messages generated as a result of an input event in a dialog box, message box, menu, or scroll bar. For more information, see the MessageProc hook procedure.
WH_SHELL
10
Installs a hook procedure that receives notifications useful to shell applications. For more information, see the ShellProc hook procedure.
WH_SYSMSGFILTER
6
Installs a hook procedure that monitors messages generated as a result of an input event in a dialog box, message box, menu, or scroll bar. The hook procedure monitors these messages for all applications in the same desktop as the calling thread. For more information, see the SysMsgProc hook procedure.
lpfn

Type: HOOKPROC

A pointer to the hook procedure. If the dwThreadId parameter is zero or specifies the identifier of a thread created by a different process, the lpfn parameter must point to a hook procedure in a DLL. Otherwise, lpfn can point to a hook procedure in the code associated with the current process.

hmod

Type: HINSTANCE

A handle to the DLL containing the hook procedure pointed to by the lpfn parameter. The hMod parameter must be set to NULL if the dwThreadId parameter specifies a thread created by the current process and if the hook procedure is within the code associated with the current process.

dwThreadId

Type: DWORD

The identifier of the thread with which the hook procedure is to be associated. For desktop apps, if this parameter is zero, the hook procedure is associated with all existing threads running in the same desktop as the calling thread. For Windows Store apps, see the Remarks section.

Return Value
Type: Type: HHOOK

If the function succeeds, the return value is the handle to the hook procedure.

If the function fails, the return value is N


发布日期:

所属分类: 易语言 标签: