GuiSendKeyEvents
- request GUI notifications for specified keys

GUI functions
(AmiBroker 6.40)


SYNTAX GuiSendKeyEvents(``string``)
RETURNS NOTHING
FUNCTION The function registers given characters to be sent as Gui event when keyboard key is pressed. GuiGetEvent will return code == notifyKeyDown and id of given character, for example id == 'D' for D letter
EXAMPLE idMyFirstButton = 1;
idMySecondButton = 2;

function CreateGUI()
{
     GuiSendKeyEvents("ED"); // send notifications for keypresses of "E" and "D"
     GuiButton( "Enable", idMyFirstButton, 10, 60, 100, 30, notifyClicked );
     GuiButton( "Disable", idMySecondButton, 110, 60, 100, 30, notifyClicked );
}

function HandleEvents()
{
    for ( n = 0; id = GuiGetEvent( n, 0 ); n++ ) // get the id of the event
    {
         code = GuiGetEvent( n, 1 );

       if( code == notifyKeyDown )
       {
         switch( id )
         {
            case 'D':
               Say("pressed D key");
               break;
      
            case 'E':
               Say("pressed E key");
               break;
         }
       }
       else
         switch ( id )
         {
             case idMyFirstButton:
             // do something
            Say( "Pressed first button" );
                break;

             case idMySecondButton:
             // do something else
            Say( "Pressed second button" );
                break;

             default:
                 break;
         }
     }
}
CreateGUI();
HandleEvents();
SEE ALSO GuiGetEvent() function

References:

The GuiSendKeyEvents function is used in the following formulas in AFL on-line library:

More information:

See updated/extended version on-line.