Article View: comp.os.msdos.programmer
Article #296Re: stop CTRL_P for doing printscreen?
From: Bailey Brown
Date: Fri, 07 Aug 1992 16:13
Date: Fri, 07 Aug 1992 16:13
68 lines
2850 bytes
2850 bytes
cwilkins@irscscm.UUCP (Charlie Wilkinson) writes:
>bbrown@infonode.ingr.com (Bailey Brown) writes:
>: I am writing a program and I want to use the CTRL_P key combination
>: in it. I am using bioskey() to read keys. When I press "ctrl-p"
>: my program does not see it, and when I exit my program, I get an
>: "abort retry fail ignore" message because the printer isn't turned
>: on. At first I thought 4dos was up to something, but the docs say
>: that ctrl-p is intercepted by the bios and has something to do
>: with printscreen. I there any way to get around this behavior?
>
>If you aren't too squeamish, you could write an new keyboard interrupt,
>or at least enough to grab the ^P and notify your program, and then
>chain to the original keyboard interrupt(?). -or you could convert the
>^P to some more harmless character, feed it to the original kbd int and
>let your program detect the character at that point by more conventional
>means. No, I've never done it before either, but it should be a piece of
>cake. ;-)
>Hope this can at least be loosely construed as "help".
Well, while looking for some sample code to install a keyboard
interrupt handler, I came across the following code that lets
you detect and read any key combo, including ctrl+p, without
starting the "printer not ready" monkey business.
To detect a keypress:
int flags;
union REGS reg;
reg.x.ax = 0x4406;
reg.x.bx = 0;
int86(0x21,®,®);
flags = reg.h.al;
if (flags & 1)
return TRUE;
else
return FALSE;
and to read the key:
int c;
union REGS reg;
reg.h.ah = 0x10;
int86(0x16, ®, ®);
c = reg.x.ax;
if ((c & 0xff) == 0 || (c & 0xff) == 0xe0)
c = (c >> 8) | 0x1080;
else
c &= 0xff;
c = c & 0x10ff;
return c;
Is this code general? Will it work on any (386 AT or better) dos box?
How does it work? It looks like it is getting the key from dos. I
thought dos was higher level than the bios, and therefore would
have as least as much bad ctrl+p type behavior as the bios.
Please shed some light. All I know is this works on my machine.
------------
Bailey Brown "Above all else, confusion reigns."
Intergraph Corporation
bbrown@casca.b11.ingr.com Procol Harum
Technical Details
Message-ID:
<1992Aug7.161317.11967@infonode.ingr.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!infonode!bbrownReferences:
<1992Jul30.041220.8028@infonode.ingr.com> <1992Aug6.155723.12195@irscscm.UUCP>Show Full Headers
Complete Article Headers
Newsgroups: comp.os.msdos.programmer Path: arc1-ca.pugleaf.net!sparky!uunet!infonode!bbrown From: bbrown@infonode.ingr.com (Bailey Brown) Subject: Re: stop CTRL_P for doing printscreen? Message-ID: <1992Aug7.161317.11967@infonode.ingr.com> Organization: Intergraph Corporation, Huntsville, AL. References: <1992Jul30.041220.8028@infonode.ingr.com> <1992Aug6.155723.12195@irscscm.UUCP> Date: Fri, 7 Aug 1992 16:13:17 GMT Lines: 68