资源简介
C++钩子模仿按键精灵屏幕录制

代码片段和文件信息
// #include
// #include
// #include “../Common/Definition.h“
// using namespace std;
#include “KMHookDll.h“
CKMHookDll* CKMHookDll::m_pInstance = NULL;
BOOL WINAPI DllMain(HINSTANCE hinstDLLDWORD fdwReasonLPVOID lpvReserved )
{
CKMHookDll::GetInstance()->SetGlobalInstance(hinstDLL);
return TRUE;
}
LRESULT CALLBACK RecHook(int codeWPARAM wParamLPARAM lParam)
{
static int recOK = 1;
if(code<0)
{
return CallNextHookEx(CKMHookDll::GetInstance()->GetRecHook()codewParamlParam);
}
else if(code==HC_SYSMODALON)
{
recOK = 0;
}
else if(code==HC_SYSMODALOFF)
{
recOK = 1;
}
else if(recOK && (code==HC_ACTION))
{
EVENTMSG action = *(EVENTMSG*)lParam;
//此处根据条件过滤
// if (action.message == WM_LBUTTONDOWN || action.message == WM_LBUTTONUP)
// {
// return 0;
// }
CKMHookDll::GetInstance()->AddEvent(action);
//m_vecAction.push_back(action);
//recordedEvent++;
}
return 0;
}
LRESULT CALLBACK PlayHook(int codeWPARAM wParamLPARAM lParam)
{
static BOOL fDelay;
static int playOK = 1;
if(code<0)
{
return CallNextHookEx(CKMHookDll::GetInstance()->GetPlayHook()codewParamlParam);
}
else if(code==HC_SYSMODALON)
{
playOK = 0;
}
else if(code==HC_SYSMODALOFF)
{
playOK = 1;
}
else if(playOK && (code==HC_GETNEXT))
{
if(fDelay)
{
fDelay = FALSE;
return 50;
}
*((EVENTMSG*)lParam) = CKMHookDll::GetInstance()->GetVecAt(CKMHookDll::GetInstance()->GetPlayedEvent());
}
else if(playOK && (code==HC_SKIP))
{
fDelay = TRUE;
CKMHookDll::GetInstance()->IncPlayedEvent();
}
if(CKMHookDll::GetInstance()->GetPlayedEvent()>=CKMHookDll::GetInstance()->GetVecSize())
{
UnhookWindowsHookEx(CKMHookDll::GetInstance()->GetPlayHook());
}
return 0;
}
CKMHookDll::CKMHookDll()
: m_bIsKeyDown(false)
m_bIsMouseDown(false)
m_bIsMouseMove(false)
m_pVecAction(NULL)
m_hRecHook(NULL)
m_hPlayHook(NULL)
m_nPlayedEvent(0)
{
m_pVecAction = new vector;
}
CKMHookDll::~ CKMHookDll()
{
}
CKMHookDll* CKMHookDll::GetInstance()
{
if (m_pInstance == NULL)
{
m_pInstance = new CKMHookDll;
}
return m_pInstance;
}
void CKMHookDll::InstallHook(bool bIsKeyDownbool bIsMouseDownbool bIsMouseMove/*HWND hwnd*/)
{
if (!m_pVecAction->empty())
{
m_pVecAction->clear();
}
m_bIsKeyDown = bIsKeyDown;
m_bIsMouseDown = bIsMouseDown;
m_bIsMouseMove = bIsMouseMove;
m_hRecHook = SetWindowsHookEx(WH_JOURNALRECORD(HOOKPROC)RecHookm_hInst0);
}
void CKMHookDll::UnInstallHook()
{
UnhookWindowsHookEx(m_hRecHook);
}
void CKMHookDll::Runscript()
{
m_nPlayedEvent = 0;
m_hPlayHook = SetWindowsHookEx(WH_JOURNALPLAYBACK(HOOKPROC)PlayHookm_hInst0);
}
void CKMHookDll::SetGlobalInstance(HINSTANCE instance)
{
m_hInst = instance;
}
HHOOK CKMHookDll::GetRecHook()
{
return m_hRecHook;
}
HHOOK CKMHookDll::GetPlayHook()
{
return m_hPlayH
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 3414 2016-03-24 14:11 MFCApplication1\KMHookDll\KMHookDll.cpp
文件 19 2016-03-23 11:07 MFCApplication1\KMHookDll\KMHookDll.def
文件 986 2016-03-24 14:24 MFCApplication1\KMHookDll\KMHookDll.h
文件 7385 2016-03-24 13:55 MFCApplication1\KMHookDll\KMHookDll.vcxproj
文件 2485 2016-03-24 14:08 MFCApplication1\MFCApplication1\MFCApplication1.cpp
文件 496 2016-03-24 14:08 MFCApplication1\MFCApplication1\MFCApplication1.h
文件 10766 2016-03-24 14:24 MFCApplication1\MFCApplication1\MFCApplication1.rc
文件 6210 2016-03-24 14:24 MFCApplication1\MFCApplication1\MFCApplication1.vcxproj
文件 3760 2016-03-24 14:25 MFCApplication1\MFCApplication1\MFCApplication1Dlg.cpp
文件 684 2016-03-24 14:25 MFCApplication1\MFCApplication1\MFCApplication1Dlg.h
文件 4013 2016-03-24 14:08 MFCApplication1\MFCApplication1\ReadMe.txt
....... 67777 2012-01-11 01:22 MFCApplication1\MFCApplication1\res\MFCApplication1.ico
文件 686 2016-03-24 14:08 MFCApplication1\MFCApplication1\res\MFCApplication1.rc2
文件 1248 2016-03-24 14:25 MFCApplication1\MFCApplication1\resource.h
文件 148 2016-03-24 14:08 MFCApplication1\MFCApplication1\stdafx.cpp
文件 1578 2016-03-24 14:08 MFCApplication1\MFCApplication1\stdafx.h
文件 234 2016-03-24 14:08 MFCApplication1\MFCApplication1\targetver.h
..A..H. 58 2016-03-24 14:08 MFCApplication1\MFCApplication1.opensdf
文件 1378 2016-03-24 14:24 MFCApplication1\MFCApplication1.sln
..A..H. 23040 2016-03-24 14:24 MFCApplication1\MFCApplication1.v11.suo
目录 0 2016-03-24 14:08 MFCApplication1\MFCApplication1\res
目录 0 2016-03-24 14:30 MFCApplication1\KMHookDll
目录 0 2016-03-24 14:30 MFCApplication1\MFCApplication1
目录 0 2016-03-24 14:29 MFCApplication1
----------- --------- ---------- ----- ----
136365 24
- 上一篇:C++读取和保存 txt 格式数据文件的方法
- 下一篇:堆排序C语言实现
相关资源
- 国际象棋的qt源代码
- C++中头文件与源文件的作用详解
- C++多线程网络编程Socket
- VC++ 多线程文件读写操作
- 利用C++哈希表的方法实现电话号码查
- 移木块游戏,可以自编自玩,vc6.0编写
- C++纯文字DOS超小RPG游戏
- VC++MFC小游戏实例教程(实例)+MFC类库
- 连铸温度场计算程序(C++)
- 6自由度机器人运动学正反解C++程序
- Em算法(使用C++编写)
- libstdc++-4.4.7-4.el6.i686.rpm
- VC++实现CMD命令执行与获得返回信息
- 白话C++(全)
- C++标准库第1、2
- 大数类c++大数类
- C++语言编写串口调试助手
- c++素数筛选法
- C++ mqtt 用法
- 商品库存管理系统 C++ MFC
- c++ 多功能计算器
- C++17 In Detail
- 嵌入式QtC++编程课件
- 颜色识别形状识别STM103嵌入式代码
- c++ 邮件多附件群发
- c++ 透明代理(hookproxy)
- mfc 调用redis
- FTP客户端源码(c++)
- c++ 画图(14Qt-XPS)
- c++多边形交并差运算
评论
共有 条评论