龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > 软件开发 > VC开发 >

用Visual C++实现屏幕抓程序(4)

时间:2009-12-30 15:42来源:未知 作者:admin 点击:
分享到:
#define MAX_KEY 100 #define CTRLBIT 0x04 #define ALTBIT 0x02 #define SHIFTBIT 0x01 #pragma data_seg("shareddata") HHOOK hHook =NULL; UINT nHookCount =0; static UCHAR HotKey[MAX_KEY] = {0}; //hotkey sta
#define MAX_KEY 100
#define CTRLBIT 0x04
#define ALTBIT 0x02
#define SHIFTBIT 0x01
#pragma data_seg("shareddata")
HHOOK hHook =NULL;
UINT nHookCount =0;
static UCHAR HotKey[MAX_KEY] = {0}; //hotkey
static UCHAR HotKeyMask[MAX_KEY] = {0}; //flag for hotkey, value is VK_CONTRL or VK_NEMU or VK_SHIFT
static HWND hCallWnd[MAX_KEY] = {0}; //window associated with hotkey
static int KeyCount =0;
static UCHAR MaskBits =0; //00000 Ctrl Alt Shift
#pragma data_seg()
HINSTANCE hins;
void VerifyWindow();
BEGIN_MESSAGE_MAP(CHookApp, CWinApp)
//{{AFX_MSG_MAP(CHookApp)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

CHookApp::CHookApp()
{
 // TODO: add construction code here,
 // Place all significant initialization in InitInstance
}

CHookApp theApp;
LRESULT CALLBACK KeyboardProc(int nCode,WPARAM wParam,LPARAM lParam)
{
 BOOL bProcessed=FALSE;
 if(HC_ACTION==nCode)
 {
  if((lParam&0xc0000000)==0xc0000000){// Key up
   switch(wParam)
   {
    case VK_MENU:
     MaskBits&=~ALTBIT;
     break;
    case VK_CONTROL:
     MaskBits&=~CTRLBIT;
     break;
    case VK_SHIFT:
     MaskBits&=~SHIFTBIT;
     break;
    default: //judge the key and send message
     break;
   }
   for(int index=0;index    if(hCallWnd[index]==NULL)
     continue;
    if(IsWindow(hCallWnd[index])&&(HotKey[index]==wParam)&&(HotKeyMask[index]==MaskBits))
    {
     SendMessage(hCallWnd[index],WM_HOTKEY,wParam,WM_KEYUP);
     bProcessed=TRUE;
    }
   }
  } 
  else if((lParam&0xc000ffff)==1){ //Key down
   switch(wParam)
   {
    case VK_MENU:

精彩图集

赞助商链接