// Gray.cpp : Defines the entry point for the application.
//
#include "stdafx.h"
#include <windows.h>
HHOOK g_hHook = NULL;//全局钩子函数句柄
BOOL __stdcall EnableAll(HWND hWnd, LPARAM lParam) {
if (!IsWindowEnabled(hWnd)) {
EnableWindow(hWnd, TRUE);
}
return TRUE;
}
//鼠标钩子函数
LRESULT CALLBACK HookProc( int code, WPARAM wParam,LPARAM lParam )
{
HWND hwnd;
POINT point;
GetCursorPos(&point);//得到鼠标位置
hwnd=WindowFromPoint(point);//得到包含鼠标的窗口句柄
EVENTMSG *event=(EVENTMSG *)lParam;
if(event->message==WM_LBUTTONDOWN)//是否为鼠标左键
{
hwnd = GetForegroundWindow();
EnumChildWindows(hwnd,EnableAll, 0);
}
return CallNextHookEx(g_hHook,code,wParam,lParam);
}
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
g_hHook=SetWindowsHookEx(WH_JOURNALRECORD,HookProc,GetModuleHandle(NULL),0);
if(g_hHook)
MessageBox(NULL,"加载钩子成功","OK",MB_OK);小弟水平有限,只好用MessageBox来阻止程序往下执行,这里不能点确定,否则程序就运行结束了,不知道有没有什么好的方法不用MessageBox,这样太丑陋了
UnhookWindowsHookEx(g_hHook);//卸载钩子
return 0;
}
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课