CAPTURAR COMBINACION DE TECLAS
HOLA GRACIAS POR DARSE TIEMPO PARA LEER MI MENSAJE BIEN ALGUIEN PODRIA AYUDARME A CAPTURAR LAS COMBINACIONES DE TECLAS EN C
EJEMPLO Alt+X o Alt+F4 gracias
EJEMPLO Alt+X o Alt+F4 gracias
// program GetKey.cpp
// borland c++ - ver 3.1 - 12/4/2004
#include <conio.h>
#include <iostream.h>
#include <iomanip.h>
#include <dos.h>
#define N 8
struct Node
{
char *msg;
int mask;
};
Node x[N] = {{"right shift",1},{"left shift",2},
{"ctrl",4},{"alt",8},
{"scroll lock",16},{"num lock",32},
{"caps lock",64},{"insert",128}};
int KbStatus()
{
union REGS ireg;
ireg.h.ah = 0x02;
int86(0x16,&ireg,&ireg);
return ireg.h.al;
} // KB STATUS
void Check() // control de las "teclas pegajozas", que son las teclas
{ // que siguen actuando aun despues de ser apretadas.
int status = KbStatus();
for(int i = 0;i < N;i++)
{
cout << setw(20) << x[i].msg << " : ";
if(status & x[i].mask)
cout << "ON";
else
cout << "OFF";
cout << endl;
}
cout << "----------------------------------------------" << endl;
} // CHECK
void main()
{
clrscr();
char a = '*';
while(a != 27) // las teclas corrientes envian un codigo ascii
{ // con valores entre 0 a 255 (8 bits)
if(kbhit()) // las teclas de control necesitan numeros mas
{ // altos, por eso mandan dos valores, el primero
a = getch(); // cero y el segundo ascii comun.
if(!a)
{
cout << setw(23) << "control key : ";
a = getch();
}
else
cout << setw(23) << "regular key : ";
cout << a << " . . . " << int(a) << endl;
Check();
}
}
getch();
} // MAIN
// borland c++ - ver 3.1 - 12/4/2004
#include <conio.h>
#include <iostream.h>
#include <iomanip.h>
#include <dos.h>
#define N 8
struct Node
{
char *msg;
int mask;
};
Node x[N] = {{"right shift",1},{"left shift",2},
{"ctrl",4},{"alt",8},
{"scroll lock",16},{"num lock",32},
{"caps lock",64},{"insert",128}};
int KbStatus()
{
union REGS ireg;
ireg.h.ah = 0x02;
int86(0x16,&ireg,&ireg);
return ireg.h.al;
} // KB STATUS
void Check() // control de las "teclas pegajozas", que son las teclas
{ // que siguen actuando aun despues de ser apretadas.
int status = KbStatus();
for(int i = 0;i < N;i++)
{
cout << setw(20) << x[i].msg << " : ";
if(status & x[i].mask)
cout << "ON";
else
cout << "OFF";
cout << endl;
}
cout << "----------------------------------------------" << endl;
} // CHECK
void main()
{
clrscr();
char a = '*';
while(a != 27) // las teclas corrientes envian un codigo ascii
{ // con valores entre 0 a 255 (8 bits)
if(kbhit()) // las teclas de control necesitan numeros mas
{ // altos, por eso mandan dos valores, el primero
a = getch(); // cero y el segundo ascii comun.
if(!a)
{
cout << setw(23) << "control key : ";
a = getch();
}
else
cout << setw(23) << "regular key : ";
cout << a << " . . . " << int(a) << endl;
Check();
}
}
getch();
} // MAIN
