Ver Mensaje Individual
  #2  
Antiguo 21-11-2014
Avatar de aguml
aguml aguml is offline
Miembro
 
Registrado: may 2013
Posts: 885
Reputación: 11
aguml Va por buen camino
Este me funciona fenomenal pero no me evita que se ejecute el atajo de teclas en la ventana en que esté en ese momento:

Trozo de codigo de Unit1.h:
Código PHP:
   //Comprobamos si se pulsó algún atajos de teclado
   
switch(Combinacion)
   {
      case 
HacerClic:
         
ButtonClic->Click();
         
Sleep(150);
         break;

      case 
Cerrar:
         
ButtonClose->Click();
         break;

      case 
Activar:
         
ButtonEnable->Click();
         break;

      case 
Desactivar:
         
ButtonDisable->Click();
         break;

      case 
Mostrar:
         
ButtonShow->Click();
         break;

      case 
Ocultar:
         
ButtonHide->Click();
         break;

      case 
Maximizar:
         
ButtonMaximize->Click();
         break;

      case 
Restaurar:
         
ButtonRestore->Click();
         break;

      case 
Minimizar:
         
ButtonMinimize->Click();
         break;

      case 
SiempreEncima:
         
ButtonTopmost->Click();
         break;

      case 
NoEncima:
         
ButtonNonTop->Click();
         break;

      case 
Enviar:
         
ButtonSendCaption->Click();
         break;
   } 
Funcion que controla las pulsaciones:
Código PHP:
/*==============================================================
    ESTA FUNCIÓN ES LA QUE CAPTURA LAS TECLAS DE CONTROL
==============================================================*/
bool KeyLogger(int *combinacion)
{
   
bool retval false;
   *
combinacion 0;
   
   if(
GetAsyncKeyState(VK_LCONTROL)==OK){ //si está pulsada [Ctrl(Izq)]
      
retval true;
   }else if(
GetAsyncKeyState(VK_RCONTROL)==OK){ //si está pulsada [Ctrl(Dcha)]
      
retval true;
   }else if((
GetKeyState(76) < 0) && ((GetKeyState(VK_LCONTROL) < 0) || (GetKeyState(VK_RCONTROL) < 0))){ //si pulsamos [Alt+L]
      
*combinacion HacerClic;
   }else if((
GetKeyState(67) < 0) && ((GetKeyState(VK_LCONTROL) < 0) || (GetKeyState(VK_RCONTROL) < 0))){ //si pulsamos [Alt+C]
      
*combinacion Cerrar;
   }else if((
GetKeyState(65) < 0) && ((GetKeyState(VK_LCONTROL) < 0) || (GetKeyState(VK_RCONTROL) < 0))){ //si pulsamos [Alt+A]
      
*combinacion Activar;
   }else if((
GetKeyState(68) < 0) && ((GetKeyState(VK_LCONTROL) < 0) || (GetKeyState(VK_RCONTROL) < 0))){ //si pulsamos [Alt+D]
      
*combinacion Desactivar;
   }else if((
GetKeyState(77) < 0) && ((GetKeyState(VK_LCONTROL) < 0) || (GetKeyState(VK_RCONTROL) < 0))){ //si pulsamos [Alt+M]
      
*combinacion Mostrar;
   }else if((
GetKeyState(79) < 0) && ((GetKeyState(VK_LCONTROL) < 0) || (GetKeyState(VK_RCONTROL) < 0))){ //si pulsamos [Alt+O]
      
*combinacion Ocultar;
   }else if((
GetKeyState(88) < 0) && ((GetKeyState(VK_LCONTROL) < 0) || (GetKeyState(VK_RCONTROL) < 0))){ //si pulsamos [Alt+X]
      
*combinacion Maximizar;
   }else if((
GetKeyState(82) < 0) && ((GetKeyState(VK_LCONTROL) < 0) || (GetKeyState(VK_RCONTROL) < 0))){ //si pulsamos [Alt+R]
      
*combinacion Restaurar;
   }else if((
GetKeyState(73) < 0) && ((GetKeyState(VK_LCONTROL) < 0) || (GetKeyState(VK_RCONTROL) < 0))){ //si pulsamos [Alt+I]
      
*combinacion Minimizar;
   }else if((
GetKeyState(83) < 0) && ((GetKeyState(VK_LCONTROL) < 0) || (GetKeyState(VK_RCONTROL) < 0))){ //si pulsamos [Alt+S]
      
*combinacion SiempreEncima;
   }else if((
GetKeyState(78) < 0) && ((GetKeyState(VK_LCONTROL) < 0) || (GetKeyState(VK_RCONTROL) < 0))){ //si pulsamos [Alt+N]
      
*combinacion NoEncima;
   }else if((
GetKeyState(69) < 0) && ((GetKeyState(VK_LCONTROL) < 0) || (GetKeyState(VK_RCONTROL) < 0))){ //si pulsamos [Alt+E]
      
*combinacion Enviar;
   }

   return 
retval;
}
//--------------------------------------------------------------------------- 
Si por ejemplo estoy seleccionando un texto del notepad y doy a Ctrl+C me funciona mi codigo perfectamente pero tambien me copia el texto que estaba seleccionado al portapapeles. Eso es lo que me gustaria evitar que, por ejemplo en este caso, no se entere de que tiene que copiar al portapapeles.
Responder Con Cita