
#include
#include
The # pragma data_seg (" mydata ")
HHOOK h_gHook=NULL;
HHOOK h_gHook1=NULL;
HWND g_hwnd=NULL;
LPMOUSEHOOKSTRUCT pMouseHook=NULL;
HWND glhPrevTarWnd=NULL;//referred to in the last time the mouse window
HWND glhDisplayWnd=NULL;//edit box shows the target window handle
HINSTANCE glhInstance=NULL;//DLL instance handle
Char strMsg [100]={0};
# pragma data_seg ()
# pragma comment (would, "/section: mydata, RWS")
LRESULT a CALLBACK MouseProc (
Int nCode,
WPARAM WPARAM,
LPARAM LPARAM
) {
//pMouseHook=(MOUSEHOOKSTRUCT FAR *) lParam;
LParam pMouseHook=(MOUSEHOOKSTRUCT *);
If (WM_MOUSEMOVE==wParam) {
If (nCode>=0) {
/* access window title */
HWND glhTargetWnd=pMouseHook - & gt; The HWND;//get the target window
HWND ParentWnd=glhTargetWnd;
Int I=1000;
UpdateWindow (glhTargetWnd);
If (glhTargetWnd!=NULL) {
GetWindowText (glhTargetWnd, strMsg, 100);
SetWindowText (GetDlgItem (g_hwnd, 1001), strMsg);
}
/* access to the parent window title */
GlhTargetWnd=GetParent (glhTargetWnd);
//get the application window handle
If (glhTargetWnd!=NULL) {
GetWindowText (glhTargetWnd, strMsg, 100);
SetWindowText (GetDlgItem (g_hwnd, 1000), strMsg);
}
/* get child window title */
GlhTargetWnd=WindowFromPoint (pMouseHook - & gt; Pt);
//glhTargetWnd=GetWindow (glhTargetWnd GW_OWNER);
If (glhTargetWnd!=NULL) {
//glhTargetWnd=ChildWindowFromPoint (glhTargetWnd pMouseHook - & gt; Pt);
GetWindowText (glhTargetWnd, strMsg, 100);
SetWindowText (GetDlgItem (g_hwnd, 1002), strMsg);
}
}
}
If (WM_RBUTTONDOWN==wParam) {
SendMessage (g_hwnd WM_CLOSE, 0, 0);
UnhookWindowsHookEx (h_gHook);
UnhookWindowsHookEx (h_gHook1);
}
Return CallNextHookEx (h_gHook, nCode wParam, lParam);
}
LRESULT a CALLBACK KeyboardProc (
Int nCode,
WPARAM WPARAM,
LPARAM LPARAM
) {
If (VK_RETURN==wParam | | VK_TAB==wParam | | VK_F2==wParam) {
SendMessage (g_hwnd WM_CLOSE, 0, 0);
UnhookWindowsHookEx (h_gHook);
UnhookWindowsHookEx (h_gHook1);
}
Return CallNextHookEx (h_gHook1, nCode wParam, lParam);
}
Void SetHook (HWND HWND) {
G_hwnd=HWND;
Hook1 glhInstance=GetModuleHandle (" ");
H_gHook=SetWindowsHookEx (WH_MOUSE MouseProc, glhInstance, 0).
H_gHook1=SetWindowsHookEx (WH_KEYBOARD KeyboardProc, glhInstance, 0).
}
CodePudding user response:
Word is used more hook API: from screen TextOutCodePudding user response:
That can source to come over, I'm a freshman, found there are some about the word from the screen, but most of them were transferred to an article, but I also copy, the result is always wrong, a little error is fatal to me, because the other is too complicated, can't debuggingCodePudding user response:
This kind of question, generally do not give a complete source code, are generally not prompt you to how to solve the concrete solution depends on yourself,CodePudding user response:
The original poster can be called powerword DLL CSDN offer interface specifications, search, and to write their own must be HOOK system function,