Board index » delphi » <<HELP>> Re-entrering TSR

<<HELP>> Re-entrering TSR

Could a tp5 specialist give me a sensible suggestion on how to re-enter a
tsr.
What I am trying to do is an tsr starting in a hotkey combination by
intercepting the keyboard handler, so far so good i got that part working
OK.
Whitin the tsr I need to stuff characters in the keyboard buffer followed
by a CR which is also working perfectly.
What is the way to enter the hot-key mask and scancodes in the keyboard
buffer so the tsr will be activated after the normal program has processed
the stuffed characters and CR and meets the hot-key in the buffer.
I can put the hot-key in the buffer, it is echoed to screen so it is still
there but probably the keybord handler is before that stage and does not
see it.
Which high tech pascal specialist can suggest a good solution to this
problem??

Ciou martin

 

Re:<<HELP>> Re-entrering TSR


Quote
Martin J. Brockhus wrote:

> Could a tp5 specialist give me a sensible suggestion on how to re-enter a
> tsr.
> What I am trying to do is an tsr starting in a hotkey combination by
> intercepting the keyboard handler, so far so good i got that part working
> OK.
> Whitin the tsr I need to stuff characters in the keyboard buffer followed
> by a CR which is also working perfectly.
> What is the way to enter the hot-key mask and scancodes in the keyboard
> buffer so the tsr will be activated after the normal program has processed
> the stuffed characters and CR and meets the hot-key in the buffer.
> I can put the hot-key in the buffer, it is echoed to screen so it is still
> there but probably the keybord handler is before that stage and does not
> see it.
> Which high tech pascal specialist can suggest a good solution to this
> problem??

> Ciou martin

Hi Martin,

What you actually want is not to re-enter the TSR but to keep the TSR
feeding the foreground program with commands (each consisting of some
chars and then Enter).

The TSR could not be possibly reactivated by a hot-key combination stored
into the keyboard buffer, because it monitors the hardware (keyboard
interrupt) and not the buffer for its hot-key.

I could suggest three different ways to implement what I believe you want
to do.

1. Hook interrupt 16h, which is called when a program calls READKEY,
KEYPRESSED or something equivalent, and stuff the commands from there,
one character at a time, instead of putting them into the keyboard
buffer. The foreground program would never know the difference. The
hot-key would just activate a flag into the TSR, to start intercepting
int 16h requests. Beware though, this is called a macro driver and it is
not very easy to implement.

2. Hook interrupt 8 (timer) or interrupt 28h (DOS-idle) and from there
check if the keyboard buffer is empty. If so, that means the foreground
program has consumed the last command and it is about time to store the
next into the keyboard buffer.

3. Instead of hooking interrupts, you could just install a new large
enough keyboard buffer to accomodate the maximun total length of the
commands you want to feed to the foreground program (I am not quite sure
but I think there are some variables in the BIOS data segment 40h that
contain the starting address, size, head and tail of the keyboard buffer;
if you change their contents to point to some area inside your TSR, you
will actually have installed a new keyboard buffer).

I hope it helps

Votis

Re:<<HELP>> Re-entrering TSR


Quote
> 3. Instead of hooking interrupts, you could just install a new large
> enough keyboard buffer to accomodate the maximun total length of the
> commands you want to feed to the foreground program (I am not quite sure
> but I think there are some variables in the BIOS data segment 40h that
> contain the starting address, size, head and tail of the keyboard buffer;
> if you change their contents to point to some area inside your TSR, you
> will actually have installed a new keyboard buffer).

You can certainly install a new keyboard buffer.  There is an example
program in PC System Programming / PCIntern / TP System Programming.
Sorry I can't give you the precise blurb, but I don't have the book
handy.

Paul

**********************************************
* http://pallando.trin.cam.ac.uk/users/pdm23 *
* mailto:pd...@cam.ac.uk                     *
**********************************************

Re:<<HELP>> Re-entrering TSR


Quote
Paratiritis <paratiritis.the.forthnet...@popper.forthnet.gr> wrote:
>The TSR could not be possibly reactivated by a hot-key combination stored
>into the keyboard buffer, because it monitors the hardware (keyboard
>interrupt) and not the buffer for its hot-key.
>...
>2. Hook interrupt 8 (timer) or interrupt 28h (DOS-idle) and from there
>check if the keyboard buffer is empty. If so, that means the foreground
>program has consumed the last command and it is about time to store the
>next into the keyboard buffer.

Another possibility.  This might be more complicated, I'm not sure.  Sort of
related to #2 above.

Hook the keyboard handler to wait for the hotkey like you have been.  However,
instead of automatically starting your TSR, have this routine place a special
code in the keyboard buffer that is impossible to generate with the keyboard.  I
believe there are some combinations that are never used as scancodes.

Next, hook into int8 (timer) to check the keyboard buffer for this special
character.  Once you see this character, stuff whatever you need into the
buffer, followed by this character again if you need to stuff something else.

The only problem with this is that you have to make sure you don't spend too
much time in the int8 routine, otherwise it will appear as though your computer
locked up.

Hope it works/helps...

---------------------------------------------------------------------
 Douglas Creager                  |  kings...@netpath.net
 WebMaestro, Eastern Alamance HS  |  http://www.netpath.net/~eastern
---------------------------------------------------------------------

Other Threads