资源简介
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语言实现
相关资源
- C++读取和保存 txt 格式数据文件的方法
- c++ 使用while读取不定量的输入数据方
- SLICSuperpixels 超像素分割图 C++代码
- NMEA0183解析 c++
- WindowsVC++获取CPU整体使用率
- viterbi译码算法c++实现以及程序所对应
- Visual C++ 开发OPC 客户端
- 贪吃蛇 小游戏 代码C++编写,面向对象
- c++分数评价
- vc++ 运用MFC实现基于AfxMessageBox的 自定
- VC++中文繁体、简体BIG-GBK编码转换程序
- 学生考勤管理系统源代码
- C++实现Apriori算法
- c++实现的读写csv文件
- C++ Prime Plus中文版第六版
- 钱能c++程序设计教程修订版答案
- 用C\\C++实现操作系统经典同步问题,
- Visual C++ 2013 从入门到精通源代码
- C++商店购物系统课程设计论文
- C++版本的百度搜索爬虫获取搜索结果
- 利用opengl 组件的基础上使用VC++编写的
- CC++ To Delphi转换器(源码)
- C++程序设计朱金付版课后习题答案
- C++上机实验答案 朱金付版
- 动态规划解TSP(旅行商)问题C++源码
- C++五子棋程序代码基础实现
- VC++编写DLL导出函数及其调用方法
- C++电梯调度系统源代码
- 理财管理系统 c++代码
- 基于QT的用C++编写的中国象棋软件源代
评论
共有 条评论