Hi Abeb,
Abeb ha scritto:
How can i catch that num-lock was pressed (or any other key like
ctrl,shift,alt) and force num-lock on?
useing gtwvt
thanks
abe.
try code below I wrote some time ago for xharbour, not tested with
current harbour SVN.
Best Regards
Francesco
-------------------------------------------
#include "common.ch"
PROCEDURE MAIN()
? "Set capslock ON"
SetCapsLock( TRUE )
Inkey( 0 )
? "Set numlock ON"
SetNumLock( TRUE )
Inkey( 0 )
? "CAPSLOCK state is : " + IIF( GetCapsLock(), "ON ", "OFF" )
? "NUMLOCK state is : " + IIF( GetNumLock(), "ON ", "OFF" )
Inkey( 0 )
? "Disable capslock"
SetCapsLock( FALSE )
Inkey( 0 )
? "Disable numlock"
SetNumLock( FALSE )
Inkey( 0 )
? "CAPSLOCK state is : " + IIF( GetCapsLock(), "ON ", "OFF" )
? "NUMLOCK state is: " + IIF( GetNumLock(), "ON ", "OFF" )
Inkey( 0 )
RETURN
#pragma BEGINDUMP
#include <windows.h>
#include "hbapi.h"
#define TOGGLED 0x0001
void SetKeyLock( BYTE vKey, BOOL bState )
{
BOOL bCurrentState;
bCurrentState = ( GetKeyState( vKey ) & TOGGLED );
if( (bState && !bCurrentState) ||
(!bState && bCurrentState) )
{
// Simulate a key press
keybd_event( vKey,
0,
KEYEVENTF_EXTENDEDKEY | 0,
0 );
// Simulate a key release
keybd_event( vKey,
0,
KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP,
0);
}
}
BOOL GetKeyLock( int vKey )
{
return ( GetKeyState( vKey ) & TOGGLED );
}
HB_FUNC( SETCAPSLOCK )
{
SetKeyLock( VK_CAPITAL, hb_parl( 1 ) );
}
HB_FUNC( SETNUMLOCK )
{
SetKeyLock( VK_NUMLOCK, hb_parl( 1 ) );
}
HB_FUNC( GETCAPSLOCK )
{
hb_retl( GetKeyLock( VK_CAPITAL ) );
}
HB_FUNC( GETNUMLOCK )
{
hb_retl( GetKeyLock( VK_NUMLOCK ) );
}
#pragma ENDDUMP
_______________________________________________
Harbour mailing list
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour