send function keys to a legacy DOS program

Alexander Gattin xrgtn at yandex.ru
Sat Mar 19 19:30:29 EDT 2011


On Sun, Mar 20, 2011 at 12:52:28AM +0200,
Alexander Gattin wrote:
> On Thu, Mar 10, 2011 at 04:58:53PM -0800, Justin
> Ezequiel wrote:
> > We have an old barcode program (MSDOS and source code unavailable.)
> > I've figured out how to populate the fields (by hacking into one of
> > the program's resource files.)
> > However, we still need to hit the following function keys in sequence.
> > F5, F2, F7
> > Is there a way to pipe said keys into the program?
> 
> It's a very old and good known trick IMO. You just
> need to write keycodes to kbd ring buffer in BIOS
> data area (I don't remember exact address,
> soemewhere in 1st 4kbytes of PC memory), then wait
> till the scancode gets consumed. I'd put "scancode
> feeding" code into timer interrupt handler.

Taken from RBIL/MEMORY.LST
(http://www.cs.cmu.edu/~ralf/interrupt-list/inter61c.zip):

--------K-M0040001A--------------------------
MEM 0040h:001Ah - KEYBOARD - POINTER TO NEXT CHARACTER IN KEYBOARD BUFFER
Size:   WORD
SeeAlso: MEM 0040h:001Ch,MEM 0040h:0080h,MEM 0040h:0082h,INT 16/AH=00h
--------K-M0040001C--------------------------
MEM 0040h:001Ch - KEYBOARD - POINTER TO FIRST FREE SLOT IN KEYBOARD BUFFER
Size:   WORD
SeeAlso: MEM 0040h:001Ah,MEM 0040h:001Eh,MEM 0040h:0080h,MEM 0040h:0082h
SeeAlso: INT 16/AH=00h
--------K-M0040001E--------------------------
MEM 0040h:001Eh - KEYBOARD - DEFAULT KEYBOARD CIRCULAR BUFFER
Size:   16 WORDs
SeeAlso: MEM 0040h:001Ah,MEM 0040h:001Ch,MEM 0040h:0080h,MEM 0040h:0082h
SeeAlso: INT 16/AH=00h,INT 16/AH=05h

Buffer is considered empty if
word[0x41A]==word[0x41C] IIRC.

You need to place 2 bytes into the circular buffer
to simulate key press. Lower byte is ASCII code,
higher byte is scan code (they are the same for
functional keys, whe using default keycode set#1):

F5: 0x3F 0x3F
F2: 0x3C 0x3C
F7: 0x41 0x41

-- 
With best regards,
xrgtn



More information about the Python-list mailing list