by emotta_no » Wed Jul 23, 2014 2:12 pm
Antonio, the funcion "SenKey" is with bug... I developed a new function SendKey. Please, see it.
- Code: Select all Expand view
#include "fivewin.ch"
Function TestSendKey()
Local nKey
Local oWnd
Private oTimer,oTimer2
DEFINE WINDOW oWnd TITLE "3D objects"
ACTIVATE WINDOW oWnd On Init (MyHook(oWnd))
Return
Static Function MyHook(oWnd)
DEFINE TIMER oTimer OF oWnd INTERVAL 100 ACTION Processar_Tecla()
oTimer:Activate()
Return
Static Function Processar_Tecla()
ThreadSleep(3000) // wait for open notepad
MySendText("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