Home > Software engineering >  Dynamic update of the current mouse coordinates global mouse hook
Dynamic update of the current mouse coordinates global mouse hook

Time:10-05

MFC beginner, previously made a keyboard keys, and now doing a through global mouse hook, inside the exe can dynamically update the current mouse coordinates of dot, saw many articles to turn over've finished writing my BBS, compiler is passed, but the results can't use,,, best can be run at a time when the mouse coordinates, then don't update,,
With the sendmessage
This is the mouse hook DLL code inside the
 LRESULT CALLBACK KeyboardProc (int nCode, WPARAM WPARAM, LPARAM LPARAM) 
{
If (nCode==HC_ACTION) {
Lparam MSLLHOOKSTRUCT * PKBHS=(MSLLHOOKSTRUCT *);
SendMessage (glhWnd WM_MYMSG, PKBHS - & gt; Pt. X, PKBHS - & gt; Pt. Y);
}
Return CallNextHookEx (glhHook, nCode wparam, lparam);//continue to send messages
}


This is exe
 LRESULT CGetMouseExeDlg: : OnMYMSG (WPARAM WPARAM, LPARAM LPARAM) 
{
Cstrings STR.
STR. The Format (_T (" X: Y % d: % d ", wParam, lParam));//formatting the mouse coordinates information and save to the cstrings type variable STR
GetDlgItem (IDC_EDIT1) - & gt; SetWindowText (STR);//update the program window text Edit control
return 1;
}

Want to show a great god and baa has a fault,,,

CodePudding user response:

Baidu search relevant keywords,

CodePudding user response:

1: hook installation is successful? When installing hooks dwThreadId is 0?
2: if (nCode & gt;=HC_ACTION) in the DLL OutputDebugString output debugging information to see if successful?

VC6 MSDN examples include complete SPY++ source can under reference

CodePudding user response:

Add the log debug to a file, to see whether the hook can get normal mouse events related notice, and then see if your exe can receive your hooks sent messages,
  • Related