input capture

i want to find a way to know where is the mouse on the screen, even if the mouse is out of the active form, and how to do a screenshoot.
the third part is the keyboard:i would know how to read directly from the keyboard, even is the program is not active.
ralph78Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

rene100Commented:
hi ralph..

a) var
   P: TPoint;
   begin
   GetCursorPos(P);
   end;

b)
Handle:=GetDesktopWindow;
Handle:=GetWindowDC(Handle);
BitBlt(image1.canvas.handle,0,0,form2.width,form2.height,Handle,0,0,SRCCOPY);

that copies the screen to a canvas (here image1.canvas).


c) you have to install a hook:

to install the hook for the keyboard :
myhook:=setwindowshookex(wh_keyboard, @clavier_hook_msg, system.hInstance, 0);

where clavier_hook_msg is a callback procedure defined as follow :
function clavier_hook_msg(code: Integer; wparam: Word; lparam: Longint): longint; stdcall;
begin
  if (code<0) then
    result:=callnexthookex(clavier_crochet, Code, wparam, lparam)
  else
  begin
    your_job;
    result:=0; {continue the message to other hook/windows <>0 stop the message}
  end;
end;

wparam will containt the virtual key code of the pressed key and iparam some information about keyboard status

and finally to iuninstall the hook :
unhookwindowshookex(myhook);


regards
rene
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
men xinCEOCommented:
@_@
0
MadshiCommented:
The hook function must be in a dll. Otherwise it won't work system wide...

Regards, Madshi.
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

rene100Commented:
ralph?
0
men xinCEOCommented:
another way,you may use setcapture.

menxin
0
men xinCEOCommented:
if you only want to know mouse's pos,you can use mouse.cursorpos.

menxin
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.