
18.01.2011, 13:59
|
Прохожий
|
|
Регистрация: 14.01.2011
Сообщения: 28
Репутация: 10
|
|
кто может вот етот хук со скриншотом сделать
вот по клику на мышку в определенном окне (ICQ) делается скриншот
вот функция
Код:
var
r: integer; //это у нас будет счетчик имени файла
//даллее идет процедурка для создания скрин шотов, нашел где в инете
procedure ScreenShot(x: Integer;
y: Integer;
Width: Integer;
Height: Integer;
bm: TBitMap);
var
dc: HDC;
lpPal: PLOGPALETTE;
begin
if ((Width = 0) or
(Height = 0)) then
Exit;
bm.Width := Width;
bm.Height := Height;
{get the screen dc}
dc := GetDc(0);
if (dc = 0) then
Exit;
{do we have a palette device?}
if (GetDeviceCaps(dc, RASTERCAPS) and
RC_PALETTE = RC_PALETTE) then
begin
{allocate memory for a logical palette}
GetMem(lpPal,
SizeOf(TLOGPALETTE) +
(255 * SizeOf(TPALETTEENTRY)));
{zero it out to be neat}
FillChar(lpPal^,
SizeOf(TLOGPALETTE) +
(255 * SizeOf(TPALETTEENTRY)),
#0);
{fill in the palette version}
lpPal^.palVersion := $300;
{grab the system palette entries}
lpPal^.palNumEntries :=
GetSystemPaletteEntries(dc,
0,
256,
lpPal^.palPalEntry);
if (lpPal^.PalNumEntries <> 0) then
{create the palette}
bm.Palette := CreatePalette(lpPal^);
FreeMem(lpPal, SizeOf(TLOGPALETTE) +
(255 * SizeOf(TPALETTEENTRY)));
end;
{copy from the screen to the bitmap}
BitBlt(bm.Canvas.Handle,
0,
0,
Width,
Height,
Dc,
x,
y,
SRCCOPY);
{release the screen dc}
ReleaseDc(0, dc);
end;
Тут с ножатием на бутон в моем приложение
Код:
procedure TForm1.Button1Click(Sender: TObject); //клик по кнопке
var
x,y: integer; //координаты курсора
begin
x:=Mouse.CursorPos.X; //соотвествено х
y:=Mouse.CursorPos.Y; //и собственно игрек
//GetCursorPos(pt);
ScreenShot(x-50,y-50,100,100, Image1.Picture.Bitmap); //делаем скрин шот нужного размера в нужном месте
image1.Picture.SaveToFile(inttostr(r)+'.bmp'); //сохраняем в файл скрин
r:=r+1; //добавляем единичку чтобы следующий скрин сохранился под другим именем
end;
|