Board index » delphi » Source Code for a Key Capture Program

Source Code for a Key Capture Program

Quote
teamw...@spectra.net (Steven Wozniak) writes:
> Does anyone have or know how to write the source code to make a key
> capture program?

I assume you mean a TSR that will monitor the keyboard.  In general,
you need to latch the keyboard interrupt and then use the keep;
procedure to go resident.  Of course, you need to be careful about
things like rentrant calls.

Here's some code to get you started (I'm typing this in.. so watch for
typos.. and sorry for the sloppy code):

{$M xxx,xxx,xxx}  (* Make sure to limit the memory you use! *)
uses dos;

const
  kbdint = $09;

var
  regs : registers;
  OldKbdVec : Pointer;

Procedure STI;
Inline($FB);

Procedure CLI;
Inline($FA);

Procedure CallOldInt(Sub:Pointer);
Begin
  Inline($9C/
         $FF/$5E/$06);
End;

Procedure KeyBoard(Flags,CS,IP,AX,BX,CX,DX,
                   SI,DI,DS,ES,BP : Word); Interrupt;
Begin
  CallOldInt(OldKbdVec);  (* Call the old interrupt to process the key
                             if you don't use it *)
  STI;
End;

BEGIN (* Main *)
  GetIntVec(KbdInt, OldKbdVec);
  SetIntVec(KbdInt, @Keyboard);
  Keep(0);
END.

Hope that helps..
later..

--- Kyle Oppenheim  kyl...@andrew.cmu.edu
         Home Page: http://www.contrib.andrew.cmu.edu/~kyleo/kyle.html
Illusion Home Page: http://www.contrib.andrew.cmu.edu/~kyleo/illusion.html

 

Re:Source Code for a Key Capture Program


Quote
teamw...@spectra.net (Steven Wozniak) wrote:
>Does anyone have or know how to write the source code to make a key
>capture program?

>                    Woz

I've written something similar in ASM, but i'm not quite sure as to how
it would be done exactly in pascal, but the abstract algorythm would look
something like this:

save interrupt vector value for int 9
change interrupt vector nine to point to my code
  my code:
    check for keypress, if so log, pass control back to
    previous address of int 9

if you're using a log file, you might also want to tag onto the disk
read/write interrupts so that you don't write keystrokes to a file and
make the little hard drive light blink when nothing should be happening.

--
          + James Lee * Co-System Administrator: WLJSHS +
     + http://io.wl.k12.in.us/~sleej * sl...@io.wl.k12.in.us +
+ Experience with QB, TP, C, C++, 8086 ASM, OOP, UNIX Programming +

Other Threads