1. Still working on the keyboard: is this function available in Euphoria??
- Posted by "paul larmuseau" <plarmuseau at pandora.be> Dec 20, 2003
- 405 views
community.borland.com Article #16214: Stuff The Keyboard Buffer Technical Notes Database TN1214C.txt Stuff The Keyboard Buffer Category :C++ Platform :All Product :C++ All Description: /* SIMULATE KEYSTROKES Often one needs to simulated keystrokes: to automate data entry, to insert standard text into an editor ( just like THELP ) etc. etc. BIOS (ATs and above ) provides a function to stuff keys into the BIOS keyboard buffer. The following is a generic function which takes an ASCIIZ string and inserts the contents of the latter in the keyboard buffer (NOTE: The keyboard buffer is 16 bytes long but only 15 characters can be inserted) followed by a Carriage Return. It is useful when writing a 'MENU' like program which would could create a batch file based on the user's requests and *stuff* the name of the batch file in the keyboard buffer prior to exiting. The last command in the batch file would run the Menu program again ! */ #include /*[]----------------------[ STUFF KEYBOARD USING STRING]------------------[] This function stuffs the keyboard buffer with the contents of an ASCIIZ string... A carriage return is appended... */ int StuffKbd( char *); int StuffKbd( char *str ) { _AL = 0x00; // Assume success ! while(*str && !_AL) // While successful and more characters { _AH = 0x05; // Function 05: Kbd Buffer Write _CH = 0x00; // Scan Code is Zero _CL = *str++; // Load ASCII Code geninterrupt(0x16); // Interrupt 16H } if (!_AL) // If successful in last call { _CX = 0x1C0D; // Load Carriage Return _AH = 0x05 ; // Function 05: Kbd Buffer Write geninterrupt(0x16); // Interrupt 16H } return (_AL); // Return 0: Success - 1: Failure } int main(void) { StuffKbd("DIR C:\\"); // Request Directory Listing of Root return 0; // End ... } Reference: 7/2/98 10:42:21 AM Last Modified: 01-SEP-99 ----- Original Message ----- From: "Bernie Ryan" <xotron at bluefrognet.net> To: <EUforum at topica.com> Sent: Saturday, December 20, 2003 5:14 PM Subject: Proxy source code Atten: Kat > > > Kat: > Here is a small proxy written in "C" which can be easily adapted > to Euphoria. > http://www.programmersheaven.com/zone15/cat241/17838.htm > Bernie > > > > TOPICA - Start your own email discussion group. FREE! > >
2. Re: Still working on the keyboard: is this function available in Euphoria??
- Posted by "Hayden McKay" <hmck1 at dodo.com.au> Dec 21, 2003
- 394 views
Isn't the keyboard buffer 32 bytes long starting at 0040:001E (#41E)? Or is the 32 Byte word at 0040:001E just the start position of keyb buffer? How did you get 16 bytes long? I would like some help on this one as I have been stuck writing keyb buffer stuff in the past because of some confution here. ----- Original Message ----- From: "paul larmuseau" <plarmuseau at pandora.be> To: <EUforum at topica.com> Sent: Sunday, December 21, 2003 10:02 AM Subject: Still working on the keyboard: is this function available in Euphoria?? > > > community.borland.com > > Article #16214: Stuff The Keyboard Buffer > > Technical Notes Database > > TN1214C.txt Stuff The Keyboard Buffer > Category :C++ > Platform :All > Product :C++ All > > Description: > /* > > SIMULATE KEYSTROKES > > Often one needs to simulated keystrokes: to automate data entry, to insert > standard text into an editor ( just like THELP ) etc. etc. BIOS (ATs and > above ) provides a function to stuff keys into the BIOS keyboard buffer. > The following is a generic function which takes an ASCIIZ string and inserts > the contents of the latter in the keyboard buffer (NOTE: The keyboard buffer > is 16 bytes long but only 15 characters can be inserted) followed by a > Carriage Return. It is useful when writing a 'MENU' like program which > would could create a batch file based on the user's requests and *stuff* the > name of the batch file in the keyboard buffer prior to exiting. The last > command in the batch file would run the Menu program again ! > */ > #include > /*[]----------------------[ STUFF KEYBOARD USING STRING]------------------[] > This function stuffs the keyboard buffer with the contents of an ASCIIZ > > string... A carriage return is appended... > */ > int StuffKbd( char *); > int StuffKbd( char *str ) > { > _AL = 0x00; // Assume success ! > while(*str && !_AL) // While successful and more characters > { > _AH = 0x05; // Function 05: Kbd Buffer Write > _CH = 0x00; // Scan Code is Zero > _CL = *str++; // Load ASCII Code > geninterrupt(0x16); // Interrupt 16H > } > if (!_AL) // If successful in last call > { > _CX = 0x1C0D; // Load Carriage Return > _AH = 0x05 ; // Function 05: Kbd Buffer Write > geninterrupt(0x16); // Interrupt 16H > } > return (_AL); // Return 0: Success - 1: Failure > } > int main(void) > { > StuffKbd("DIR C:\\"); // Request Directory Listing of Root > return 0; // End ... > } > > > Reference: > > > 7/2/98 10:42:21 AM > Last Modified: 01-SEP-99 > > ----- Original Message ----- > From: "Bernie Ryan" <xotron at bluefrognet.net> > To: <EUforum at topica.com> > Sent: Saturday, December 20, 2003 5:14 PM > Subject: Proxy source code Atten: Kat > > > > Kat: > > Here is a small proxy written in "C" which can be easily adapted > > to Euphoria. > > http://www.programmersheaven.com/zone15/cat241/17838.htm > > Bernie > > > > > > TOPICA - Start your own email discussion group. FREE! > > > > > > > TOPICA - Start your own email discussion group. FREE! > > > -- > Incoming mail is certified Virus Free. > Checked by AVG anti-virus system (http://www.grisoft.com). > Version: 6.0.551 / Virus Database: 343 - Release Date: 11/12/03 > --- --
3. Re: Still working on the keyboard: is this function available in Euphoria??
- Posted by "Juergen Luethje" <j.lue at gmx.de> Dec 21, 2003
- 403 views
Hayden McKay wrote: > Isn't the keyboard buffer 32 bytes long starting at 0040:001E (#41E)? Normally, yes. But begin and size of the keyboard buffer can be changed by software, so it's safer that your program looks for the actual values on the special computer in the very moment, when it's running. > Or is the 32 Byte word at 0040:001E just the start position of keyb buffer? No. The 2 byte word at 0040:0080 (#0480) contains the start position of the DOS keyboard buffer, see below. > How did you get 16 bytes long? The DOS keyboard buffer _normally_ has a size of 32 bytes. Since each key occupies 2 bytes, there is space for 16 keys. Because it's a circular buffer, only 15 keys actually can be used. > I would like some help on this one as I have been stuck writing keyb buffer > stuff in the past because of some confution here. The same happened to me, when I first loked into this stuff. The following is a translation of a PowerBASIC program that I wrote several years ago, to Euphoria. ---------------------------[ begin program ]--------------------------- global type pointer (object x) -- 32 bit pointer if atom(x) and (x = floor(x)) and (x >= 0) and (x <= #FFFFFFFF) then return 1 end if return 0 end type global function peek2u (object memory) -- usage: val = peek2u(addr) -- s = peek2u({addr, count}) -- returns unsigned 2-byte-integers atom addr integer count sequence s if atom(memory) then return and_bits(peek4u(memory), #FFFF) else addr = memory[1] count = memory[2] s = repeat(0, count) for i = 1 to count do s[i] = and_bits(peek4u(addr), #FFFF) addr += 2 end for return s end if end function global function GetKbdLoc () -- return address and size (number of keys) of the DOS keyboard buffer -- (each key occupies 2 bytes). pointer addr integer offBufBeg, offBufEnd, numKeys offBufBeg = peek2u(#0480) -- offset of begin of buffer, normally #001E offBufEnd = peek2u(#0482) -- offset of end of buffer, normally #003E addr = #0400 + offBufBeg -- segment of BIOS data = #0040 -- (address = segment*#10 + offset) numKeys = floor((offBufEnd-offBufBeg)/2) - 1 return {addr, numKeys} end function -- Demo include get.e -- for wait_key() sequence temp temp = GetKbdLoc() printf(1, "Address of DOS keyboard buffer: #%04x\n", {temp[1]}) printf(1, "Size of DOS keyboard buffer (number of keys): %d\n", {temp[2]}) puts(2, "\nPress any key ...") if wait_key() then end if ----------------------------[ end program ]---------------------------- <snipped old text> Regards, Juergen -- /"\ ASCII ribbon campain | |\ _,,,---,,_ \ / against HTML in | /,`.-'`' -. ;-;;,_ X e-mail and news, | |,4- ) )-,_..;\ ( `'-' / \ and unneeded MIME | '---''(_/--' `-'\_)