From: dspascha@eos.ncsu.edu (DAVID SCOTT PASCHAL)
Subject: Re: Keyboard Interrupt
Originator: dspascha@c00085-100lez.eos.ncsu.edu
Reply-To: dspascha@eos.ncsu.edu (DAVID SCOTT PASCHAL)
Organization: North Carolina State University, Project Eos
Date: Thu, 27 Aug 1992 21:02:32 GMT


In article <g89f2900.4.714907231@giraffe.ru.ac.za>, g89f2900@giraffe.ru.ac.za (MR BRI FAWTHROP) writes:
|> Path: taco!rock!stanford.edu!ames!haven.umd.edu!uunet!zephyr.ens.tek.com!psgrain!hippo!bs-pc3-06.ru.ac.za!g89f2900
|> From: g89f2900@giraffe.ru.ac.za (MR BRI FAWTHROP)
|> Newsgroups: alt.msdos.programmer
|> Subject: Keyboard Interrupt
|> Message-ID: <g89f2900.4.714907231@giraffe.ru.ac.za>
|> Date: Thu, 27 Aug 92 05:20:31 GMT+5:00
|> Sender: news@hippo.ru.ac.za
|> Organization: Rhodes University, Grahamstown, South Africa
|> Lines: 34
|> 
|> Hi
|> 
|> I am trying to write  program  which reads the keyboard buffer, before the 
|> command.com interrupter does.
|> In other words
|> I want to write a program that if certain keywords are typed in it will go 
|> and do some function.
|> otherwise it must act as normal.
|> 
|> eg
|>  enter CLS
|>    I want it to first do the normal clearscreen 
|>    but afterwards it must print my name and time and other tings on the top 
|>    of the screen.
|>         ( I will write the program that prints my name and other things )
|>         ( But I need to know how to link in the keyboard interrupt   so )
|>         ( that when it reads CLS if first does CLS and then comes and   )
|>         ( executes my program. )
|> 
|>  OR
|>  enter TIME
|>    I want it to ask me if I want to change the time or just display it.
|>    THEN it must go and do the NORMAL time function.
|>           ( same applies here I will write the program but how do I )
|>           ( link it into the keyboard interrupt )
|> 
|> Does anyone know if this is possible ???
|> 
|> PLEASE I HAVE BEEN TRYING FOR +/- 4 mths. BUT no-one I have asked knows
|> what to do or even how to HELP
|> 
|> Barry Fawthrop.
|> g89f2900@giraffe.ru.ac.za
|>   
|> 

Hi.  This seems rather difficult to do with a keyboard intercept, partly because
it would be difficult to determine whether or not you're sitting at a
COMMAND.COM C:\> prompt or in an application program.  What I would suggest is
this: take a disk editor and "hack" up COMMAND.COM -- find where in the file it
stores its command table, and replace maybe the first letter of each command
you want to change with an underscore (or whatever character you want to use --
just be sure it's some character allowed in a filename).  So let's say you've
changed "TIME" and "CLS" to "_IME" and "_LS".  Now create some batch files
called "TIME.BAT" and "CLS.BAT" that say something like the following:

CLS.BAT:
_ls
echo Hi.  This is my computer.  Hope you enjoy it.

TIME.BAT:
echo Hi.  Do you want to change the time? (Y/N)
yesno
if errorlevel 1 goto settime
_ime<newline.txt
goto end
:settime
time
:end

In addition, you'll need to create a file with a single blank line called
"newline.txt" (or whatever you want to call it) that when fed into the standard
input of the _IME command will do the same thing as pressing <Enter> at the
"Enter new time" prompt.  You'll also need to find or write a short program
that waits for a Y or N to be pressed on the keyboard and returns exit code 1
if Y or y pressed, otherwise exit code 0.  But this shouldn't be too hard to
write.  (I suppose a lot easier than writing a keyboard interrupt handler to
do all this!)  :-)

Hope this helps.

Tschuess,
David Paschal
Newsgroups: alt.msdos.programmer