Record Mouse Movement And KeyDown

Experts....................

my delphi app sits in the traybar and when run a setup.exe
(any setup.exe) i want to monitor mouse movement and keystrokes in INI file, like some macro program do. I will be able to play it again with same speed and all?

I raise the points for complete code and answer

Points = ?

Regards
Karen
karen021897Asked:
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.

MadshiCommented:
You'll need to call SetWindowsHookEx(WH_JOURNALRECORD, ...). Quite difficult stuff. Sorry, I've no time to write you some sources.
However, I don't understand what this has to do with "ini" files???

Regards, Madshi.
0
MadshiCommented:
P.S: The hook callback function for SetWindowsHookEx must be in a little self-written DLL, if you want it to work system-wide (that's what I guess)...
0
nricoCommented:
You could use a very accurate timer (it's him with his timers again :-), to monitor the mouse-movement through Mouse.CursorPos.X and Y. As for the keys, you need to hook the Windows keyboard handler, for which I have an example here:

http://www.experts-exchange.com/jsp/qShow.jsp?ta=delphi&qid=10171257 

Also, you can find a very accurate timer here:

http://www.silicmdr.com/Freeware.htm

But I do not know how to find out when a file called setup.exe is run. Sorry.

Hope these links will help,
Rico
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

MadshiCommented:
Oops... I missed the part with the setup.exe. Which Delphi version do you have, karen?
0
AswCommented:
Hi Karen,

Try www.cyamon.com and download Recorder.

Asw
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
yingkitCommented:
Recorder in www.cyamon.com seems to be unable to save the keystrokes and mouse movements into files.
After the termination of the program, all recorded keys, movt will be lost...
Anyway, it works fine if save is not required.
0
nricoCommented:
But *HOW* does it work?
0
craig_capelCommented:
well i know yet another method of recording the mouse movement, and i can even capture the keyboard using port $60 and that works.... there is only one thing i can not do with the mouse though, and that is to determine what mouse button get pressed, i can click on the buttons where the mouse is, control the mouse and do almost anything..... heres the code for all to see....

unit mouse1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ExtCtrls, StdCtrls;

type
  TForm1 = class(TForm)
    Timer1: TTimer;
    Button1: TButton;
    Button2: TButton;
    SaveDialog1: TSaveDialog;
    Edit1: TEdit;
    Button3: TButton;
    Edit2: TEdit;
    procedure Timer1Timer(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure FormMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
 
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
    fn: string;

implementation

{$R *.DFM}

procedure TForm1.Timer1Timer(Sender: TObject);
var
 p: trect;
  fm,lm: word;
  n: integer;
  result: byte;
  t: textfile;
  x,y,num,num1,num2: integer;
  ms: dword;
  wnd: hwnd;
  tt: tmsg;
  p2: tpoint;
begin
  system.assign(t,fn);
  system.append(t);
  num:=getmessagepos();
   num1:=hiword(num);
   num2:=loword(num);
      p2.y:=num1;
      p2.x:=num2;
   wnd:=windowfrompoint(p2);
   asm
    in al,$60;
    mov result,al;
   end;
      if result=$3d then enablewindow(wnd,false);
       if result=$3e then enablewindow(wnd,true);
   edit1.text:=inttostr(wnd);

   writeln(t,num1);
   writeln(t,num2);
{   edit1.text:=inttostr(num1);
   edit2.text:=inttostr(num2);}
   system.close(t);
   x:=num2;
   y:=num1;
         {tt.hwnd:=form1.Handle;
         tt.message:=qs_mousebutton;}
          getmessage(nil,wnd,fm,lm);
{   ms:=getqueuestatus(QS_MOUSEBUTTON);}
   edit2.text:=inttostr(fm);

end;

procedure TForm1.Button1Click(Sender: TObject);
var
 tmp: string;
 t: textfile;
 slw,x,y,n: integer;
begin
 timer1.enabled:=false;
system.assign(t,fn);
  system.reset(t);
  repeat
        readln(t,tmp);
    readln(t,tmp);
    y:=strtoint(tmp);
    x:=strtoint(tmp);
     for slw:=1 to 10000 do
       application.processmessages;
    setcursorpos(x,y);
  until eof(t);
  system.close(t);
end;

procedure TForm1.Button2Click(Sender: TObject);
var
 t: textfile;
begin
savedialog1.execute;
fn:=savedialog1.filename;
  system.assign(t,fn);
  system.rewrite(t);
  timer1.enabled:=true;
    system.close(t);
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
if timer1.enabled=false then
close;
end;

procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
edit2.text:=' test';
end;

end.


i am hopeing some here knows the reverse command of....
sendmessage, and if i found out that, then you would not need a hook :)

Craig C.
0
craig_capelCommented:
oops, i forgot to see if the program works.....

procedure TForm1.Button1Click(Sender: TObject);
var
 tmp: string;
 t: textfile;
 slw,x,y,n: integer;
begin
 timer1.enabled:=false;
system.assign(t,fn);
  system.reset(t);
  repeat
        readln(t,tmp);
    y:=strtoint(tmp);
        readln(t,tmp);
    x:=strtoint(tmp);
     for slw:=1 to 10000 do
       application.processmessages;
    setcursorpos(x,y);
  until eof(t);
  system.close(t);
end;

this needs changing, and the first error message is getmessage, thats what i need help on myself :) but if you know how to make it work, half of this problem is solved... and the second error is that i read tmp twice in, just overwrite it with this code.... and then i promise it will work..

Craig C.
0
intheCommented:
theres an article with full source on this at borland:

http://community.borland.com/article/1,1410,10323,00.html
0
ahalyaCommented:
i have code for journalhook & playback, (based on borland's article), but with the following features

(1).   Save/Restore
(2).   Playback at different speeds
(3).   Hotkey activation for both recording andf playback.

i made this program to use as a "Macro" in Grapher & it ain't perfect, but it works well.

i can email you a copy, if you like.
(src is in D2: it shdn't be a concern)
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.