L
lxxiaoxiao
Unregistered / Unconfirmed
GUEST, unregistred user!
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include <stdio.h>
#include <tlhelp32.h>
#include "Unit1.h"
#include <winuser.h>
#include <windows.h>
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
long sbx,sby;
HOOKPROC JournalLogProc(int iCode,WPARAM wParam,LPARAM lParam);
//钩子变量
HHOOK g_hLogHook=NULL;
//记录上一次得到焦点的窗口句柄
HWND g_hLastFocus=NULL;
//键盘掩码变量
const int KeyPressMask=0x80000000;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
HOOKPROC JournalLogProc(int iCode,WPARAM wParam,LPARAM lParam)
{
if(iCode<0)
{
return (HOOKPROC)CallNextHookEx(g_hLogHook,iCode,wParam,lParam);
}
PMOUSEHOOKSTRUCT mouse = (PMOUSEHOOKSTRUCT)lParam;
POINT p = mouse->pt;
sbx = p.x;
sby = p.y;
return (HOOKPROC)CallNextHookEx(g_hLogHook,iCode,wParam,lParam);
}
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
Edit1->Text = AnsiString(sbx)+","+AnsiString(sby);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormShow(TObject *Sender)
{
if(g_hLogHook==NULL)//安装日志钩子
{
g_hLogHook=SetWindowsHookEx(WH_JOURNALRECORD,(HOOKPROC)JournalLogProc,HInstance,0);
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)
{
if(g_hLogHook!=NULL)
{
UnhookWindowsHookEx(g_hLogHook);
g_hLogHook=NULL;
}
}
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include <stdio.h>
#include <tlhelp32.h>
#include "Unit1.h"
#include <winuser.h>
#include <windows.h>
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
long sbx,sby;
HOOKPROC JournalLogProc(int iCode,WPARAM wParam,LPARAM lParam);
//钩子变量
HHOOK g_hLogHook=NULL;
//记录上一次得到焦点的窗口句柄
HWND g_hLastFocus=NULL;
//键盘掩码变量
const int KeyPressMask=0x80000000;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
HOOKPROC JournalLogProc(int iCode,WPARAM wParam,LPARAM lParam)
{
if(iCode<0)
{
return (HOOKPROC)CallNextHookEx(g_hLogHook,iCode,wParam,lParam);
}
PMOUSEHOOKSTRUCT mouse = (PMOUSEHOOKSTRUCT)lParam;
POINT p = mouse->pt;
sbx = p.x;
sby = p.y;
return (HOOKPROC)CallNextHookEx(g_hLogHook,iCode,wParam,lParam);
}
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
Edit1->Text = AnsiString(sbx)+","+AnsiString(sby);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormShow(TObject *Sender)
{
if(g_hLogHook==NULL)//安装日志钩子
{
g_hLogHook=SetWindowsHookEx(WH_JOURNALRECORD,(HOOKPROC)JournalLogProc,HInstance,0);
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)
{
if(g_hLogHook!=NULL)
{
UnhookWindowsHookEx(g_hLogHook);
g_hLogHook=NULL;
}
}
//---------------------------------------------------------------------------