Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

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

 
 
Herramientas Buscar en Tema Desplegado
  #4  
Antiguo 24-03-2016
Avatar de aguml
aguml aguml is offline
Miembro
 
Registrado: may 2013
Posts: 885
Poder: 14
aguml Va por buen camino
Bueno, el codigo funciona perfectamente y es este:
Código PHP:
#include <vcl.h>
#pragma hdrstop

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

#define OK -32767 //Necesario para el keylogger

LRESULT WINAPI KeyboardEvent(int nCodeWPARAM wParamLPARAM lParam);
bool CloseApp;

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;
   
Activarteclado1->Enabled=ButtonQuitarHook->Enabled;
   
Desactivarteclado1->Enabled=ButtonColocarHook->Enabled;
   
SysTrayIcon1->IconIndex=0;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::ButtonQuitarHookClick(TObject *Sender)
{
   
UnhookWindowsHookEx(hKeyboardHook);
   
ButtonColocarHook->Enabled true;
   
ButtonQuitarHook->Enabled false;
   
Activarteclado1->Enabled=ButtonQuitarHook->Enabled;
   
Desactivarteclado1->Enabled=ButtonColocarHook->Enabled;
   
SysTrayIcon1->IconIndex=1;
}
//---------------------------------------------------------------------------

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) && !GetAsyncKeyState(VK_MENU)){
         if (
count == && *(PDWORD)lParam == 'U') {        // 'u'
            
count 1;
         } else if (
count == && *(PDWORD)lParam == 'N') { // 'n'
            
count 2;
         } else if (
count == && *(PDWORD)lParam == 'L') { // 'l'
            
count 3;
         } else if (
count == && *(PDWORD)lParam == 'O') { // 'o'
            
count 4;
         } else if (
count == && *(PDWORD)lParam == 'C') { // 'c'
            
count 5;
         } else if (
count == && *(PDWORD)lParam == 'K') { // 'k'
            
count 0;
            
Form1->ButtonQuitarHook->Click();
         } else {
            
count 0;
         }
      }else{
         
count 0;
      }
      return 
1;
   }
   return 
CallNextHookEx(hKeyboardHooknCodewParamlParam);
}
//---------------------------------------------------------------------------

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

void __fastcall TForm1::FormClose(TObject *SenderTCloseAction &Action)
{
   
UnhookWindowsHookEx(hKeyboardHook);
   
ButtonColocarHook->Enabled true;
   
ButtonQuitarHook->Enabled false;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Salir1Click(TObject *Sender)
{
   
CloseApp true;
   
Close();
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Desactivarteclado1Click(TObject *Sender)
{
   
ButtonColocarHook->Click();
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Activarteclado1Click(TObject *Sender)
{
   
ButtonQuitarHook->Click();
}
//---------------------------------------------------------------------------

void __fastcall TForm1::FormCloseQuery(TObject *Senderbool &CanClose)
{
   if(
CloseApp){
      
CanClose CloseApp;
   }else{
      
CanClose=CloseApp;
      
SysTrayCanClose CanClose;
      
SysTrayIcon1->Minimize();
   }
}
//---------------------------------------------------------------------------

void __fastcall TForm1::SysTrayIcon1Minimize(TObject *Sender)
{
   
SysTrayCanClose true;
   
SysTrayIcon1->Visible true;
   
SysTrayIcon1->Hide true;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::SysTrayIcon1Restore(TObject *Sender)
{
   
SysTrayIcon1->Visible false;
   
SysTrayIcon1->Hide false;
}
//--------------------------------------------------------------------------- 
Ahora tengo un pequeño problema, se que se ha visto mas veces pero no doy con el post donde se trató, lo que deseo es que el form principal se inicie oculto ya que uso el componente SysTrayIcon que creó escafandra y quiero que arranque mostrando solo el trayicon y no lo consigo. Si que era poniendo algo en el cpp del proyecto pero no lo recuerdo.
Responder Con Cita
 


Herramientas Buscar en Tema
Buscar en Tema:

Búsqueda Avanzada
Desplegado

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 04:13:37.


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