Jump to content
Fivewin Brasil

Hook de teclado


emotta

Recommended Posts

Quero fazer um hook de teclado onde ao executa-lo ele envia um conjunto de caracteres a outro programa que estiver ativo, simulando uma digitação.

Por exemplo:

Eu estou com o editando um documento no word e tenho que digitar uma frase como "BOM DIA CLIENTE". Em vez de digitar eu aciono o meu programa desenvolvido em xHarbour e ele faz a digitação pra mim através de hook de teclado.

Pessoal, eu sei que para o exemplo acima tem inúmeras outras soluções melhores, mas o que eu quero é um exemplo de como fazer hook de teclado para o exemplo acima pois vou usar para inúmeras outras coisas que somente posso fazer através desta solução.

Qualquer outra solução que não seja fazendo Hook por favor, nao postar, pois não me terá serventia.

Obrigado

Link to comment
Share on other sites

Consegui fazer a função abaixo que captura a tecla digitada mas quando o foco está na minha window. Se eu abrir o Word e digitar ele não captura.

O segredo é aqui:

SetWindowsHookEx (WH_KEYBOARD, (HOOKPROC)KeyboardProc, (HINSTANCE) NULL, GetCurrentThreadId() );

No lugar do GetCurrentThreadId() deve ser passado 0 (zero) para que seja capturado teclas de outras aplicações também mas quando passo zero ele da erro ao "instalar" o Hook de teclado.

Alguem ai que ja mexeu com isso consegue resolver? A unica coisa que preciso a mais do que tem no exemplo é que mesmo que não se esteja no foco do meu executavel ele consiga capturar a tecla como já faz atualmente quando se está no foco.

#include "fivewin.ch"

Function TestHook()
Local nKey
Local oWnd
Private oTimer

   DEFINE WINDOW oWnd TITLE "3D objects"


   ACTIVATE WINDOW oWnd On Init (MyHook(oWnd))

IF UNINSTALL_READ_KEYBOARD() == .F.
   ? "ERROR al desinstalar READ_KEYBOARD"
ENDIF

Return

Static Function MyHook(oWnd)
msgstop("hook")

IF INSTALL_READ_KEYBOARD() == .F.
   ? 'ERROR al instalar READ_KEYBOARD'
   Return
EndIf

DEFINE TIMER oTimer OF oWnd INTERVAL 100 ACTION Processar_Tecla()
oTimer:Activate()


//While Inkey()#27
//   nKey := GET_LAST_VK()
//   If nKey # 0
//      ? nKey
//   EndIf
//EndDo
         

Return

Static Function Processar_Tecla()
Local nKey := GET_LAST_VK()
Static nKeyAnt := 0
oTimer:DeActivate()                                                           

If nKey # nKeyAnt
   nKeyAnt := nKey
   MsgStop(nKey)
EndIf
oTimer:Activate()

Return

*##################################################################################################
* FUNCIONES EN C    
*##################################################################################################

#pragma begindump

#include <windows.h>
#include "hbapi.h"

HB_BOOL flag_hhk = FALSE;
HB_BOOL PAUSE_hhk = FALSE;
HHOOK hhk = NULL;
HB_LONG VK_PRESIONADO = 0;
HB_LONG VK_lParam = 0;


HINSTANCE hinst;

LRESULT CALLBACK KeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)
{
  if (nCode < 0) 
    return CallNextHookEx(hhk, nCode, wParam, lParam);
    
  if (PAUSE_hhk == FALSE)
  { VK_PRESIONADO = (long) wParam;
    VK_lParam = (LONG) lParam;
  }
  else  
  { VK_PRESIONADO = 0;
    VK_lParam = 0;
  } 
  
  return CallNextHookEx(hhk, nCode, wParam, lParam);
}

HB_FUNC (GET_STATE_VK_SHIFT)
{
 if (GetKeyState(VK_SHIFT) & 0x8000)
   hb_retl (TRUE); 
 else  
   hb_retl (FALSE);
}

HB_FUNC (GET_STATE_VK_CONTROL)
{
 if (GetKeyState(VK_CONTROL) & 0x8000)
   hb_retl (TRUE); 
 else  
   hb_retl (FALSE);
}

HB_FUNC (GET_STATE_VK_ALT)
{
 if (GetKeyState(VK_MENU) & 0x8000)
   hb_retl (TRUE); 
 else  
   hb_retl (FALSE);
}

HB_FUNC (GET_LAST_VK)
{
 if (flag_hhk == TRUE)
   hb_retnl (VK_PRESIONADO);
 else
   hb_retnl (0);  
}

HB_FUNC (GET_LAST_VK_NAME)
{
 CHAR cadena [128];

 if (flag_hhk == TRUE)
   { GetKeyNameText (VK_lParam, (LPTSTR) &cadena, 128);
    hb_retc (cadena);
   }
 else
   hb_retc ("");  
}

HB_FUNC (PAUSE_READ_VK)
{
 if (hb_pcount () == 1 && hb_parinfo (1) == HB_IT_LOGICAL) 
 { if (hb_parl (1) == TRUE) 
   { VK_PRESIONADO = 0;
     VK_lParam = 0;
   }  
   PAUSE_hhk = hb_parl (1);
 }
}

HB_FUNC (INSTALL_READ_KEYBOARD)
{
 
 if (flag_hhk == FALSE)
 {  hhk = SetWindowsHookEx (WH_KEYBOARD, (HOOKPROC)KeyboardProc, (HINSTANCE) NULL, GetCurrentThreadId() );
    
    if (hhk == NULL) 
      hb_retl (FALSE);
    else
    { flag_hhk = TRUE;  
      hb_retl (TRUE);           
    } 
 }
 else
   hb_retl (TRUE);   
}

HB_FUNC (UNINSTALL_READ_KEYBOARD)
{
 if (flag_hhk == TRUE)
 { if (UnhookWindowsHookEx (hhk) == TRUE)
   { flag_hhk = FALSE;
     hb_retl (TRUE);     
   }
   else
     hb_retl (FALSE); 
 }
 else
   hb_retl (TRUE);   
}

#pragma enddump

Link to comment
Share on other sites

Peguei do forum da PCTOLETO mas o exemplo era pra HWGUI e mudei para ficar compativel com fivewin. A parte em C é exatamente a mesma de onde eu peguei... Mas enfim, ainda preciso da solução para o caso pois em ambos ele somente monitora o que é digitado quando a aplicação está em foco, preciso que capture também o que foi digitado quando se está fora do foco....

Link to comment
Share on other sites

Aqui é o fonte na INTEGRA, da forma como peguei... Mas ainda busco a solução para o meu caso

****************************************************************************
* PROGRAMA: READ THE KEYBOARD 
* LENGUAJE: HARBOUR-MINIGUI
* FECHA:  13 ABRIL 2010
* AUTOR:  CLAUDIO SOTO
* PAIS:  URUGUAY
* E-MAIL: srvet@adinet.com.uy
****************************************************************************

***************************************************************************************************
* DESCRIPCION
*
* Lee las entradas entradas del teclado y devuelve informacion sobre la tecla presionada. 
* Estas funciones interceptan los mensajes de teclado que el sistema le envia a la aplicacion 
* (WM_KEYUP y WM_KEYDOWN) y almacena informacion sobre la tecla virtual generada. 
*
***************************************************************************************************
* SINTAXIS:
*
* INSTALL_READ_KEYBOARD () // Instala el manejador que lee el teclado (Retorna .T. si tiene exito) 
* UNINSTALL_READ_KEYBOARD () // Desinstala el manejador que lee el teclado (Retorna .T. si tiene exito)
*
* GET_LAST_VK()       // Retorna el valor virtual (VK Code) de la tecla presionada 
* GET_LAST_VK_NAME()    // Retorna el nombre de la tecla virtual presionado
*
* GET_STATE_VK_SHIFT ()   // Retorna .T. si la tecla SHIFT esta presionada
* GET_STATE_VK_CONTROL ()  // Retorna .T. si la tecla CONTROL esta presionada
* GET_STATE_VK_ALT ()    // Retorna .T. si la tecla ALT esta presionada
*
* PAUSE_READ_VK (.T.)    // Pausa la lectura del teclado para poder procesar la tecla presionada
* PAUSE_READ_VK (.F.)    // Restablece la lectura del teclado luego de la pausa
*
***************************************************************************************************

#include "minigui.ch"

Procedure Main

 DEFINE WINDOW Form_1 ;
   AT 0,0 ;
   WIDTH 400 ;
   HEIGHT 600 ;
   TITLE 'Form_1' ;
   MAIN ;
   ON INIT On_Init(); 
   ON RELEASE On_Release()

   @ 380 , 10 LABEL Label_10 VALUE "Presionar SHIFT + A abre Caja Dialogo" AUTOSIZE BOLD

   @ 450 , 10 EDITBOX EditBox_1 WIDTH 200 HEIGHT 100 VALUE "Escribir algo" 

 END WINDOW

 DEFINE WINDOW Form_2 ;
   AT 0,0 ;
   WIDTH 300 ;
   HEIGHT 200 ;
   TITLE 'Form_2' ;
   CHILD
   @ 10 , 10 EDITBOX EditBox_1 WIDTH 200 HEIGHT 100 VALUE "Escribir algo" 
 END WINDOW

 Form_1.Center 

 ACTIVATE WINDOW Form_1, Form_2

Return

Procedure On_Init
 IF INSTALL_READ_KEYBOARD() == .F.
   MsgInfo ("ERROR al instalar READ_KEYBOARD")
 ELSE
   DEFINE TIMER timer_1 OF Form_1 INTERVAL 100 ACTION Procesar_Tecla()
 ENDIF
Return

Procedure On_Release
 IF UNINSTALL_READ_KEYBOARD() == .F.
   MsgInfo ("ERROR al desinstalar READ_KEYBOARD")
 ENDIF
Return

Procedure Procesar_Tecla
Static Flag := .F.

 IF Flag == .T.
  Return // impide la reentrada
 Endif
 Flag := .T.
 
 IF GET_LAST_VK() == 65 .AND. GET_STATE_VK_SHIFT() == .T. // VK code de A = 65
   PAUSE_READ_VK (.T.) // pausa la lectura del teclado

   Msginfo ("Procesar la accion de la tecla SHIFT + A")

   PAUSE_READ_VK (.F.) // restablece la lectura del teclado
 ENDIF
 
 Flag := .F.
Return

*##################################################################################################
* FUNCIONES EN C    
*##################################################################################################

#pragma begindump

#include <windows.h>
#include "hbapi.h"

HB_BOOL flag_hhk = FALSE;
HB_BOOL PAUSE_hhk = FALSE;
HHOOK hhk = NULL;
HB_LONG VK_PRESIONADO = 0;
HB_LONG VK_lParam = 0;

LRESULT CALLBACK KeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)
{
  if (nCode < 0) 
    return CallNextHookEx(hhk, nCode, wParam, lParam);
    
  if (PAUSE_hhk == FALSE)
  { VK_PRESIONADO = (long) wParam;
    VK_lParam = (LONG) lParam;
  }
  else  
  { VK_PRESIONADO = 0;
    VK_lParam = 0;
  } 
  
  return CallNextHookEx(hhk, nCode, wParam, lParam);
}

HB_FUNC (GET_STATE_VK_SHIFT)
{
 if (GetKeyState(VK_SHIFT) & 0x8000)
   hb_retl (TRUE); 
 else  
   hb_retl (FALSE);
}

HB_FUNC (GET_STATE_VK_CONTROL)
{
 if (GetKeyState(VK_CONTROL) & 0x8000)
   hb_retl (TRUE); 
 else  
   hb_retl (FALSE);
}

HB_FUNC (GET_STATE_VK_ALT)
{
 if (GetKeyState(VK_MENU) & 0x8000)
   hb_retl (TRUE); 
 else  
   hb_retl (FALSE);
}

HB_FUNC (GET_LAST_VK)
{
 if (flag_hhk == TRUE)
   hb_retnl (VK_PRESIONADO);
 else
   hb_retnl (0);  
}

HB_FUNC (GET_LAST_VK_NAME)
{
 CHAR cadena [128];

 if (flag_hhk == TRUE)
   { GetKeyNameText (VK_lParam, (LPTSTR) &cadena, 128);
    hb_retc (cadena);
   }
 else
   hb_retc ("");  
}

HB_FUNC (PAUSE_READ_VK)
{
 if (hb_pcount () == 1 && hb_parinfo (1) == HB_IT_LOGICAL) 
 { if (hb_parl (1) == TRUE) 
   { VK_PRESIONADO = 0;
     VK_lParam = 0;
   }  
   PAUSE_hhk = hb_parl (1);
 }
}

HB_FUNC (INSTALL_READ_KEYBOARD)
{
 if (flag_hhk == FALSE)
 {  hhk = SetWindowsHookEx (WH_KEYBOARD, KeyboardProc, (HINSTANCE) NULL, GetCurrentThreadId());
    
    if (hhk == NULL) 
      hb_retl (FALSE);
    else
    { flag_hhk = TRUE;  
      hb_retl (TRUE);           
    } 
 }
 else
   hb_retl (TRUE);   
}

HB_FUNC (UNINSTALL_READ_KEYBOARD)
{
 if (flag_hhk == TRUE)
 { if (UnhookWindowsHookEx (hhk) == TRUE)
   { flag_hhk = FALSE;
     hb_retl (TRUE);     
   }
   else
     hb_retl (FALSE); 
 }
 else
   hb_retl (TRUE);   
}

#pragma enddump

Link to comment
Share on other sites

Após muito apanhar eu consegui. O segredo era colocar o define abaixo e mudar o SetWindowsHook:

#define WH_KEYBOARD_LL 13

e

SetWindowsHookEx (WH_KEYBOARD_LL, (HOOKPROC)KeyboardProc, hInst, 0 )

Segue o fonte na integra, caso seja util pra alguem:

#include "fivewin.ch"

Function TestHook()
Local nKey
Local oWnd
Private oTimer

   DEFINE WINDOW oWnd TITLE "3D objects"


   ACTIVATE WINDOW oWnd On Init (MyHook(oWnd))

IF UNINSTALL_READ_KEYBOARD() == .F.
   ? "ERROR al desinstalar READ_KEYBOARD"
ENDIF

Return

Static Function MyHook(oWnd)
msgstop("hook")

IF INSTALL_READ_KEYBOARD() == .F.
   ? 'ERROR al instalar READ_KEYBOARD'
   Return
EndIf

DEFINE TIMER oTimer OF oWnd INTERVAL 100 ACTION Processar_Tecla()
oTimer:Activate()


//While Inkey()#27
//   nKey := GET_LAST_VK()
//   If nKey # 0
//      ? nKey
//   EndIf
//EndDo
         

Return

Static Function Processar_Tecla()
Local nKey := GET_LAST_VK()
Static nKeyAnt := 0
oTimer:DeActivate()                                                           

If nKey # nKeyAnt
   nKeyAnt := nKey
   MsgStop(nKey)
EndIf
oTimer:Activate()

Return

*##################################################################################################
* FUNCIONES EN C    
*##################################################################################################

#pragma begindump

#include <windows.h>
#include <stdlib.h>
#include "hbapi.h"

#define WH_KEYBOARD_LL 13                                               

HINSTANCE hInst ; // Instance handle


HB_BOOL flag_hhk = FALSE;
HB_BOOL PAUSE_hhk = FALSE;
HHOOK hhk = NULL;
HB_LONG VK_PRESIONADO = 0;
HB_LONG VK_lParam = 0;

LRESULT CALLBACK KeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)
{
  if (nCode < 0) 
    return CallNextHookEx(hhk, nCode, wParam, lParam);
    
  if (PAUSE_hhk == FALSE)
  { VK_PRESIONADO = (long) wParam;
    VK_lParam = (LONG) lParam;
  }
  else  
  { VK_PRESIONADO = 0;
    VK_lParam = 0;
  } 
  
  return CallNextHookEx(hhk, nCode, wParam, lParam);
}

HB_FUNC (GET_STATE_VK_SHIFT)
{
 if (GetKeyState(VK_SHIFT) & 0x8000)
   hb_retl (TRUE); 
 else  
   hb_retl (FALSE);
}

HB_FUNC (GET_STATE_VK_CONTROL)
{
 if (GetKeyState(VK_CONTROL) & 0x8000)
   hb_retl (TRUE); 
 else  
   hb_retl (FALSE);
}

HB_FUNC (GET_STATE_VK_ALT)
{
 if (GetKeyState(VK_MENU) & 0x8000)
   hb_retl (TRUE); 
 else  
   hb_retl (FALSE);
}

HB_FUNC (GET_LAST_VK)
{
 if (flag_hhk == TRUE)
   hb_retnl (VK_PRESIONADO);
 else
   hb_retnl (0);  
}

HB_FUNC (GET_LAST_VK_NAME)
{
 CHAR cadena [128];

 if (flag_hhk == TRUE)
   { GetKeyNameText (VK_lParam, (LPTSTR) &cadena, 128);
    hb_retc (cadena);
   }
 else
   hb_retc ("");  
}

HB_FUNC (PAUSE_READ_VK)
{
 if (hb_pcount () == 1 && hb_parinfo (1) == HB_IT_LOGICAL) 
 { if (hb_parl (1) == TRUE) 
   { VK_PRESIONADO = 0;
     VK_lParam = 0;
   }  
   PAUSE_hhk = hb_parl (1);
 }
}

HB_FUNC (INSTALL_READ_KEYBOARD)
{


 if (flag_hhk == FALSE)
 {  hhk = SetWindowsHookEx (WH_KEYBOARD_LL, (HOOKPROC)KeyboardProc, hInst, 0 );
    
    if (hhk == NULL) 
      hb_retl (FALSE);
    else
    { flag_hhk = TRUE;  
      hb_retl (TRUE);           
    } 
 }
 else
   hb_retl (TRUE);   
}

HB_FUNC (UNINSTALL_READ_KEYBOARD)
{
 if (flag_hhk == TRUE)
 { if (UnhookWindowsHookEx (hhk) == TRUE)
   { flag_hhk = FALSE;
     hb_retl (TRUE);     
   }
   else
     hb_retl (FALSE); 
 }
 else
   hb_retl (TRUE);   
}

#pragma enddump

Link to comment
Share on other sites

Minha idéia não é fazer um Keylogger... O que quero é quando ativar o programa e digitar uma sequencia pré-definida o programa "fazer" a digitação de uma sequencia de caracteres:

Exemplo:

Se eu digitar #BOMDIA

O programa interpreta isso e digita:

Bom dia Sr. Cliente, tudo bem? Estamos lançando uma nova versao... etc etc etc...

É apenas um utilitário pra uso pessoal mesmo pra facilitar a digitação de textos pré-definidos. Isso até já existe, o KeyText é bem completo, porem ele é pago e muitas versões que se baixam tem virus.

Postei aqui o hook pois pode ser útil em outras situações. Voce pode por exemplo, toda vez que for digitado a letra "a" mudar para "b", etc... Pode ser útil em algum caso especifico.

abraços

Motta confirma se a idéia seria maios ou menos referente a este vídeo pra termos uma idéia (assistir a partir do 2:45)

Link to comment
Share on other sites

Hook é uma maneira de "interceptar" qualquer ação do sistema operacional antes do windows processar, no caso esse que postei é um hook de teclado, mas tem de mouse, eventos e qualquer outra ação do sistema operacional. Pra quem é da velha guarda é o equivalente aos antigos "códigos de interrupção" que o DOS tinha...

vlw, é q eu já tinha ouvido falar sobre hook mas não sabia o q era, agora com este tópico deu pra ter uma ideia do q seja.

[]´s

Link to comment
Share on other sites

Eduardo, isso nao deixarai seu sistema muito lento?



#include "fivewin.ch"

STATIC oTimer, oTimer2, nKey, oWnd

Function TestSendKey()

DEFINE WINDOW oWnd TITLE "3D objects"


ACTIVATE WINDOW oWnd On Init (MyHook(oWnd))

oTimer:End()

Return

Static Function MyHook(oWnd)

DEFINE TIMER oTimer OF oWnd INTERVAL 1000 ACTION Processar_Tecla()

oTimer:Activate()

Return

Static Function Processar_Tecla()

ThreadSleep(3000) // wait for open notepad

// isso deixaria o sistema muito lento ou nao?
MySendText( Lower( "Hello World " ) )

Return

// functions SENDKEY

Static Function MySendKey(nTecla)

FWSendKey(nTecla,0) // press key

FWSendKey(nTecla,1) // unpress key

Return

Static Function MySendText(cTexto)

Local nI
Local cCar
Local lShift

For nI := 1 to Len(cTexto)

cCar := SubStr(cTexto,nI,1)
lShift := IsUpper( cCar )

If lShift
FWSendKey(16,0) // press shift key
EndIf

MySendKey(Asc(Upper(cCar)),0)

If lShift
FWSendKey(16,45) // unpress shift key
EndIf

Next

Return



*##################################################################################################
* FUNCIONES EN C
*##################################################################################################

#pragma begindump

#include <windows.h>
#include <stdlib.h>
#include "hbapi.h"


HB_FUNC( FWSENDKEY )
{
int nPress;

nPress = hb_parni(2);

if (nPress == 0)
keybd_event( hb_parni(1), nPress, KEYEVENTF_EXTENDEDKEY | 0, 0 );
else
keybd_event( hb_parni(1), nPress, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0 );

}

#pragma enddump


Link to comment
Share on other sites

Não é pra colocar no sistema, foi apenas um pequeno utilitário que fiz para uso específico... Quanto a lentidão no exemplo acima ficaria por causa do TIMER e não pelo Hook de teclado...

No caso do que voce postou é que eu precisava da função SENDKEY que é do fivewin mas ela está com GPF. Eu refiz ela corrigindo. A FWSENDKEY em nada fica lento, ele apenas simula uma digitação.

abraços

Eduardo, isso nao deixarai seu sistema muito lento?
#include "fivewin.ch"
 
STATIC oTimer, oTimer2, nKey, oWnd
 
Function TestSendKey()
 
   DEFINE WINDOW oWnd TITLE "3D objects"
 
 
   ACTIVATE WINDOW oWnd On Init (MyHook(oWnd))
 
   oTimer:End()
 
Return
 
Static Function MyHook(oWnd)
 
   DEFINE TIMER oTimer OF oWnd INTERVAL 1000 ACTION Processar_Tecla()
 
   oTimer:Activate()
 
Return
 
Static Function Processar_Tecla()
 
   ThreadSleep(3000) // wait for open notepad
 
   // isso deixaria o sistema muito lento ou nao?
   MySendText( Lower( "Hello World " ) )
 
Return
 
// functions SENDKEY
 
Static Function MySendKey(nTecla)
 
   FWSendKey(nTecla,0) // press key
 
   FWSendKey(nTecla,1) // unpress key
 
Return
 
Static Function MySendText(cTexto)
 
   Local nI
   Local cCar
   Local lShift
 
   For nI := 1 to Len(cTexto)
 
      cCar := SubStr(cTexto,nI,1)
      lShift := IsUpper( cCar )
 
      If lShift
         FWSendKey(16,0)  // press shift key
      EndIf
 
      MySendKey(Asc(Upper(cCar)),0)
 
      If lShift
         FWSendKey(16,45) // unpress shift key
      EndIf
 
   Next
 
Return
 
 
 
*##################################################################################################
* FUNCIONES EN C    
*##################################################################################################
 
#pragma begindump
 
#include <windows.h>
#include <stdlib.h>
#include "hbapi.h"
 
 
HB_FUNC( FWSENDKEY ) 
{
int nPress;
 
nPress = hb_parni(2);
 
if (nPress == 0)
   keybd_event( hb_parni(1), nPress, KEYEVENTF_EXTENDEDKEY | 0, 0 ); 
else
   keybd_event( hb_parni(1), nPress, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0 ); 
 
} 
 
#pragma enddump
Link to comment
Share on other sites

Entendi, mas qual é a finalidade desta simulação de digitação? Na prática, isso serve para que? se estou no prompt de comando, ele fica escrevendo Hello World... Se estou no meu editor for dos, ele fica escrevendo AAAAAAAAAAAAAAAAAAAAAAAAAA??

Não captei a utilidade disto... Tô 333 -> 1/2 besta. kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk

abs,

Link to comment
Share on other sites

Hello World foi um exemplo para uso da função... Se vc quiser mandar para alguma outra aplicação um conjunto de caracteres vc pode fazer isso... A aplicação manda o texto para o programa que estiver aberto.

Se vc ainda não precisou de nada assim então não tem mesmo serventia, mas se precisar de algo nessa necessidade isso será util.

Faça uns testes ai.... Divirta-se e fique pronto para se precisar...

No meu caso foi o seguinte, para automatizar respostas de um email especifico. Eu precisava escrever:

"Bom dia, seja bem vindo e bla bla bla, bla bla bla bla bla bla" e ai pressionava ENTER e a tecla TAB 4x seguidas para cair na próxima caixa de texto e digitar a mesma coisa e repetir o processo.

Bom a rotina que fiz eu automatizei isso, como falei, é pra uso especifico. Apenas posiciono o cursor na caixa de texto que preciso digitar e então digito a barra invertida ("\") e ele inicia a "digitação" e faz isso de 10x seguidas. Se quiser novamente aperto a barra invertida e ele repete.

É para uso especifico e não comercial, porem a função FWSENDKEY pode ter uso no sistema para várias situações, como por exemplo importação de dados.

Abraços

Entendi, mas qual é a finalidade desta simulação de digitação? Na prática, isso serve para que? se estou no prompt de comando, ele fica escrevendo Hello World... Se estou no meu editor for dos, ele fica escrevendo AAAAAAAAAAAAAAAAAAAAAAAAAA??

Não captei a utilidade disto... Tô 333 -> 1/2 besta. kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk

abs,

Link to comment
Share on other sites

  • 4 years later...

Sim Sistem, é possivel fazer o que deseja... Basta apenas tempo, paciencia e fuçar um pouco nisso.

Você consegue fazer isso com a FWSENDKEY que postei e alguns outros exemplos que estão aqui e em outros foruns, basta encaixar tudo. Mas é possivel fazer isso sim e inclusive é de artificios assim que empresas que fazerem disparo automático de mensagens por whatsapp usam... 

Só não posso te ajudar nisso pois estou sem tempo e não tenho interesse nesse tipo de aplicação mas não me parece ser coisa de outro mundo fazer isso não.

Link to comment
Share on other sites

Boa noite

eu compilei o programa do hook do teclado e deu erros nas linhas:

HB_BOOL flag_hhk = FALSE;
HB_BOOL PAUSE_hhk = FALSE;
HHOOK hhk = NULL;
 

deu tipo não reconhecido.

em que arquivo .h posso encontrar os comando HB_BOOL, HHOOK?

 

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...