Crash/GPF in SendKey Functon

Crash/GPF in SendKey Functon

Postby 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

 
emotta_no
 
Posts: 33
Joined: Thu Jul 04, 2013 9:28 pm

Re: Crash/GPF in SendKey Functon

Postby Horizon » Wed Jul 23, 2014 7:07 pm

Thank you emotta_no,

It worked for me.

How Can I send Tab key?
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Re: Crash/GPF in SendKey Functon

Postby emotta_no » Wed Jul 23, 2014 7:09 pm

Yes, you can...

MySendKey(VK_TAB)
emotta_no
 
Posts: 33
Joined: Thu Jul 04, 2013 9:28 pm

Re: Crash/GPF in SendKey Functon

Postby Antonio Linares » Wed Jul 23, 2014 10:03 pm

Eduardo,

I have included it this way for the next FWH version, Thanks! :-)

Code: Select all  Expand view
HB_FUNC( FW_SENDKEY )
{
   if( hb_parni( 2 ) == 0 )
      keybd_event( ( BYTE ) hb_parni( 1 ), ( BYTE ) hb_parni( 2 ),
                   KEYEVENTF_EXTENDEDKEY | 0, 0 );
   else
      keybd_event( ( BYTE ) hb_parni( 1 ), ( BYTE ) hb_parni( 2 ),
                   KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0 );
}
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Crash/GPF in SendKey Functon

Postby emotta_no » Thu Jul 24, 2014 2:23 pm

Great,
emotta_no
 
Posts: 33
Joined: Thu Jul 04, 2013 9:28 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 50 guests