eNarc
asked on
how to capture mouse in a screenshot?
this is what I'm using to process the screenshot into jpg, tho how to I capture mouse?
procedure ScreenShot2;
var
ScreenDC: HDC;
ScreenHandle: HWnd;
ScreenBitmap: TBitmap;
Jpg:TJpegImage;
filename:string;
time:string;
begin
ScreenHandle := GetDeskTopWindow;
ScreenDC := GetDC(ScreenHandle);
time:=DateTimeToStr(Now);
time:=StringReplace(time, ':', '-', [rfReplaceAll, rfIgnoreCase]);
time:=StringReplace(time, '/', '-', [rfReplaceAll, rfIgnoreCase]);
GetWindowText(GetForegroundWindow, Wnd2, SizeOf(Wnd2));
filename:=extractfilepath(paramstr(0))+'\'+wnd2+' - '+time+'.jpg';
try
ScreenBitmap := TBitMap.Create;
try
ScreenBitmap.Width := Screen.Width;
ScreenBitmap.Height := Screen.Height;
BitBlt(ScreenBitmap.Canvas.Handle, 0, 0,
Screen.Width, Screen.Height, ScreenDC, 0, 0, SRCCOPY);
// Clipboard.Assign(ScreenBitmap)
try
jpg:=TJpegImage.Create;
jpg.PixelFormat := jf24bit;
Jpg.CompressionQuality:=70;
Jpg.ProgressiveEncoding:=True;
// Jpg.Grayscale:=
Jpg.Assign(ScreenBitmap);
Jpg.SaveToFile(FileName);
finally
end;
finally
ScreenBitmap.Free
end
finally
ReleaseDC(ScreenHandle, ScreenDC)
end
end {ScreenShot};
ASKER
tho how do I put it into the function above?
for draws the current mouse cursor image ScreenShot Bitmap
for draws the current mouse cursor image ScreenShot Bitmap
procedure DrawCursor(ScreenShotBitmap : TBitmap);
var
r: TRect;
CI: TCursorInfo;
Icon: TIcon;
II: TIconInfo;
begin
r := ScreenShotBitmap.Canvas.ClipRect;
Icon := TIcon.Create;
try
CI.cbSize := SizeOf(CI);
if GetCursorInfo(CI) then
if CI.Flags = CURSOR_SHOWING then
begin
Icon.Handle := CopyIcon(CI.hCursor);
if GetIconInfo(Icon.Handle, II) then
begin
ScreenShotBitmap.Canvas.Draw(
ci.ptScreenPos.x - Integer(II.xHotspot) - r.Left,
ci.ptScreenPos.y - Integer(II.yHotspot) - r.Top,
Icon
);
end;
end;
finally
Icon.Free;
end;
end;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Perfect
http://delphi.about.com/od/graphics/l/aa021004a.htm