nacer@mist.cs.orst.edu (Abdenacer Moussaoui C.) (01/18/89)
I would like someone out there to send me a simple TSR program in
Turbo Pascal that would insert a string into the keyboard buffer. In
doing so I would you to point out briefly.
- how your program works
- what are things to watch for when using a TSR
- how can I insure that the current application gets the appropriate
keys that the TSR just inserted in the keyboard.
- you may want to include also how you would trap keys from within
your TSR program.
- How to go about deciding and restricting to a minimum the size
of your TSR (stack, DS, heap, etc...)
For simplicity assume your sample is to insert the word 'HELLO'
when the CTRL-P key is pressed for example.
I am planning to write my own keyboard macro and this part will help
me achieve that. The minimum inlines and more use of TP4 features
the better.
Thank you.
--nacer nacer@mist.cs.orst.edupilgrimk@lafcol.UUCP (Guru Jee) (01/24/89)
# I would like someone out there to send me a simple TSR program in # TP40 that would insert a string into the keyboard buffer. In # doing so I would you to point out briefly. # # - how your program works # - what are things to watch for when using a TSR # - how can I insure that the current application gets the appropriate # keys that the TSR just inserted in the keyboard. # - you may want to include also how you would trap keys from within # your TSR program. # - How to go about deciding and restricting to a minimum the size # of your TSR (stack, DS, heap, etc...) I think many others would be interseted in this topic so those of you who know, please contribute your ideas to the net and not to individuals. Thanks!
jmbj@whuts.ATT.COM (BITTMAN) (01/25/89)
> # I would like someone out there to send me a simple TSR program in > # TP40 that would insert a string into the keyboard buffer. In > # doing so I would you to point out briefly. > > I think many others would be interseted in this topic so those of > you who know, please contribute your ideas to the net and not to > individuals. > This program responds to mouse movement and button presses and "stuffs" the appropriate keys into the keyboard buffer. The code is ram-resident, and very simple, it doesn't know if it's already there, and it doesn't restore the old int 33h. It DOES demonstrate how to use the mouse and how to insert keys into the keyboard buffer. begin 644 menumouse.arc M&@A-14Y534]54RY!4TT`!08``&81`WT@UJL/```,("`EH)*$"I,B(!(FE!*F9 M30LI9>:D(5/T03=*,D?-FSALS%YN\J3.G#`@B<M+8*2.G@0*7.T22-"ER? M99N*%]/,`=$F#!PX9<B`H/,&1!TX+,B\N>.&!9LR(%FD/(/F8A@Y'.^`6%,FZ MSQR83*!>%%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_E1$39]7N5=Y>>62(GJDRI#KD3G*Q*4,+>-'AE5*^<=8?!$R4<1D(0N0UV A+T<M@,`#2V/X<*\4P0[+K[_+@1`P#T4@)H?!"LP8$!H`R `` end size 2508
nacer@mist.cs.orst.edu (Abdenacer Moussaoui C.) (01/30/89)
So far I have received nothing if I do I will post what I get to the net. The stuffing-mouse was not much help to me as I try to avoid assembly as much as I can. Let's be patient I am sure something will come along... -- nacer@mist.cs.orst.edu
wsinpp@eutrc3.UUCP (Peter Peters) (02/02/89)
How about the same program in Turbo Pascal, would
that be better ??
Comments are left out (mainly) because it's all the
same as the assembly "menumouse" you received.
Code follows behind the dotted line.
-----------------------------------------------------
Program MenuMouse;
{ A-,B-,D-,E-,F-,I-,L-,N-,O-,R-,S-,V-} (* speed up things *)
{$M 1024,0,0} (* minimum of space *)
{ Mouse Movement is mapped to up,down,left,right arrow keys
Left Button ==> <Esc>
Right Button ==> <Enter>
}
Uses
Dos;
Const
fn_home = $4700;
fn_end = $4f00;
lt_arr = $4b00;
rt_arr = $4d00;
up_arr = $4800;
dn_arr = $5000;
carr_rtn = $1c0d;
esc_key = $011b;
mouse_int = $33;
get_butt_press = 5;
read_mouse_mot = 11;
set_subr_mask = 12;
set_sens = 15;
lt_button = 0;
rt_button = 1;
vert_sens = 4;
horiz_sens = 10;
buffer_segm = $40;
buffer_length = $20;
buffer_rd_ptr = $1a;
buffer_wrt_ptr = buffer_rd_ptr+2;
buffer_start = buffer_wrt_ptr+2;
buffer_end = buffer_start+buffer_length;
horiz_pos : Integer = 0;
vert_pos : Integer = 0;
Var
Regs : Registers;
Procedure Sti;
{Enable interrupts
}
Inline ($fb);
Procedure Retf_from_interrupt;
{Exit for the mousedriver call needed while the interrupt
procedure ends with RETI and the driver expects RET FAR
mov sp,bp; pop es; pop ds; pop di; pop si; pop dx;
pop cx; pop bx; pop ax; ret far
}
Inline ($89/$ec/$5d/$07/$1f/$5f/$5e/$5a/$59/$5b/$58/$cb);
Procedure Enter (keystroke : word);
{Fake key entry in keyboard type ahead buffer
}
Var
next,curr : Word;
Begin
curr := Memw[buffer_segm:buffer_wrt_ptr];
next := curr+2;
If next = buffer_end Then
next := buffer_start;
If next <> Memw[buffer_segm:buffer_rd_ptr] Then
Begin
Memw[buffer_segm:buffer_wrt_ptr] := next;
Memw[buffer_segm:curr] := keystroke;
End;
End;
{$F+}
Procedure UserInputMask; Interrupt;
{Routine called every time a mouse movement or button
is detected. The Interrupt directive is misused here
to generate the required pushes to save all registers.
To take care of a correct return to the caller, the
procedure Retf_from_interrupt is used which pops the
pushed registers and performs a retf instead of a reti.
}
Begin
Sti;
Regs.AX := get_butt_press;
Regs.BX := lt_button;
Intr (mouse_int,Regs);
If Regs.BX <> 0 Then
Enter (esc_key)
Else
Begin
Regs.AX := get_butt_press;
Regs.BX := rt_button;
Intr (mouse_int,Regs);
If Regs.BX <> 0 Then
Enter (carr_rtn)
Else
Begin
Regs.AX := read_mouse_mot;
Intr (mouse_int,Regs);
horiz_pos := horiz_pos + Integer(Regs.CX);
If Abs(horiz_pos) >= horiz_sens Then
Begin
If horiz_pos < 0 Then
Enter (lt_arr)
Else
Enter (rt_arr);
horiz_pos := 0;
End;
vert_pos := vert_pos + Integer(Regs.DX);
If Abs(vert_pos) >= vert_sens Then
Begin
If vert_pos < 0 Then
Enter (up_arr)
Else
Enter (dn_arr);
vert_pos := 0;
End;
End;
End;
Retf_from_interrupt;
End;
{$F-}
Begin {Main}
Regs.DX := Ofs(UserInputMask);
Regs.ES := Seg(UserInputMask);
Regs.AX := set_subr_mask;
Regs.CX := $0b;
Intr (mouse_int,Regs);
Regs.AX := set_sens;
Regs.CX := horiz_sens;
Regs.DX := vert_sens;
Intr (mouse_int,Regs);
(* restore the interrupt vectors to their state they
were in before TP changed them, don't know if it's
really necessary.
*)
Swapvectors;
(* Terminate and stay resident *)
Keep (0);
End.
--------------------------------------------------------
Hope it's of any use :-)
Peter Peters.
Eindhoven University of Technology
Standard disclaimer blah blah....