Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!samsung!umich!ox.com!math.fu-berlin.de!unidui!unido!mcshh!abqhh!drdhh!bjoern From: bjoern@drdhh.hanse.de (Bjoern Kriews) Newsgroups: comp.sys.atari.st.tech Subject: Re: Simulating keypress Message-ID: <2654.04.91@drdhh.hanse.de> Date: 8 Apr 91 17:21:34 GMT References: <1991Apr5.151946.25763@etek.chalmers.se> Organization: Digital Island Lines: 35 From article <1991Apr5.151946.25763@etek.chalmers.se>, by fabian@etek.chalmers.se (Martin Fabian): > > Is there any (legal) way to simulate a keypress from inside > a program. This is not too legal, but it works: 'io' is Iorec(KBD); 'bits' are the special keys 'scan' is the keycode to be written 'k_xx' are the Keytbl() scan->ascii tables. void queue_key(unsigned int scan, unsigned int bits) { unsigned int next; if( ( next = io->ibuftl + 4 ) >= io->ibufsiz ) next = 0; if( next == io->ibufhd ) return; *(int*)((char*)io->ibuf+next = scan | bits << 8; *(int*)((char*)io->ibuf+next+2) = ( bits & KB_CAPS ? k_cl : bits & ( KB_SHIFTL | KB_SHIFTR ) ? k_sh : k_us ) [scan]; io->ibuftl = next; } Hope that helps, Bjoern --- bjoern@drdhh.hanse.de = Bjoern Kriews / Stormsweg 6 / 2000 Hamburg 76 / FRG "gaaga mahwe Bjoern urgl ufzae Turbo-C bnub" (J. Willamowius)