Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Otros entornos y lenguajes > C++ Builder
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

 
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 24-03-2016
Avatar de aguml
aguml aguml is offline
Miembro
 
Registrado: may 2013
Posts: 885
Poder: 11
aguml Va por buen camino
bloqueador de teclado antigatos

Bueno, esto suena chistoso pero estoy cansado de que mis gatos masajeen mi teclado y he estado buscando soluciones para bloquear el teclado y que por mucho que pisen no hagan ningun estropicio. Todo lo que he encontrado por la red ha sido referente a una app que haga un hook del teclado y deseche las pulsaciones hasta que haya una combinacion de teclas deseadas o una palabra o algo asi. He escrito este codigo pero funciona a medias:
Código PHP:
#include <vcl.h>
#pragma hdrstop

#include "Main.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"

#define OK -32767 //Necesario para el keylogger

LRESULT WINAPI KeyboardEvent(int nCodeWPARAM wParamLPARAM lParam);

TForm1 *Form1;
HHOOK  hKeyboardHook;
//---------------------------------------------------------------------------

__fastcall TForm1::TForm1(TComponentOwner)
   : 
TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm1::ButtonColocarHookClick(TObject *Sender)
{
   
hKeyboardHook  SetWindowsHookEx(WH_KEYBOARD_LL, (HOOKPROC)KeyboardEventGetModuleHandle(NULL), 0);
   
ButtonColocarHook->Enabled false;
   
ButtonQuitarHook->Enabled true;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::ButtonQuitarHookClick(TObject *Sender)
{
   
UnhookWindowsHookEx(hKeyboardHook);
   
ButtonColocarHook->Enabled true;
   
ButtonQuitarHook->Enabled false;
}
//---------------------------------------------------------------------------

LRESULT WINAPI KeyboardEvent(int nCodeWPARAM wParamLPARAM lParam)
{
   static 
count=0;

   if( (
nCode == HC_ACTION) && ((wParam == WM_SYSKEYDOWN) || (wParam == WM_KEYDOWN)) ){
      if(
GetAsyncKeyState(VK_CONTROL) && GetAsyncKeyState(VK_SHIFT))
      {

      }else if(
GetAsyncKeyState(VK_CONTROL) && GetAsyncKeyState(VK_MENU))
      {

      }else if(
GetAsyncKeyState(VK_CONTROL))
      {

      }else if(
GetAsyncKeyState(VK_MENU))
      {

      }else if(
GetAsyncKeyState(VK_SHIFT)){

      }else{
         if (
count == && tolower(*(PDWORD)lParam) == 'u') {        // 'u'
            
count 1;
         } else if (
count == && tolower(*(PDWORD)lParam) == 'n') { // 'n'
            
count 2;
         } else if (
count == && tolower(*(PDWORD)lParam) == 'l') { // 'l'
            
count 3;
         } else if (
count == && tolower(*(PDWORD)lParam) == 'o') { // 'o'
            
count 4;
         } else if (
count == && tolower(*(PDWORD)lParam) == 'c') { // 'c'
            
count 5;
         } else if (
count == && tolower(*(PDWORD)lParam) == 'k') { // 'k'
            
count 0;
            
Form1->ButtonQuitarHook->Click();
         } else {
            
count 0;
         }
      }
   }
   return 
CallNextHookEx(hKeyboardHooknCodewParamlParam);
}
//---------------------------------------------------------------------------

void __fastcall TForm1::FormCreate(TObject *Sender)
{
   
hKeyboardHook  SetWindowsHookEx(WH_KEYBOARD_LL, (HOOKPROC)KeyboardEventGetModuleHandle(NULL), 0);
   
ButtonColocarHook->Enabled false;
   
ButtonQuitarHook->Enabled true;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::FormClose(TObject *SenderTCloseAction &Action)
{
   
UnhookWindowsHookEx(hKeyboardHook);
   
ButtonColocarHook->Enabled true;
   
ButtonQuitarHook->Enabled false;
}
//--------------------------------------------------------------------------- 
Realmente capturo todas las pulsaciones que desee pero lo que deseo es que esas pulsaciones sean todas desechadas hasta que se desbloquee el teclado pero aunque las capturo no consigo anularlas. ¿podeis ayudarme con esto?
Responder Con Cita
 



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Bloqueador para Android FabianSiza Desarrollo en Delphi para Android 1 14-01-2015 13:22:45
teclado usb armando Varios 1 12-02-2011 04:09:00
Bloqueador solar.... RONPABLO La Taberna 5 16-07-2007 19:48:47
Teclado D-MO Linux 3 14-07-2006 21:06:07
USB Teclado en Red Hat 9 nicocer Linux 0 05-07-2004 22:04:56


La franja horaria es GMT +2. Ahora son las 12:52:33.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi