Send hotkey from EA or from Indicator

 

Hello,


Could you help me?

Possible to send hotkey from an EA or from an indicator?

For example F11 for switch fullscreen, or CTRL+F5 for next profile.

Thank you.


Steve

 

Find the command id of the menu item or hotkey in question (e.g. with WInspector). Use PostMessage() to send chart specific commands (like CTRL-F5) to the chart window and chart unspecific comands (like F11) to the terminal main window. A few examples:


/**
 * MT4 command ids (menu, toolbar and hotkey ids). ID naming and numbering conventions for resources, commands, strings,
 * controls and child windows as defined by MFC 2.0:
 *
 *  @see  https://msdn.microsoft.com/en-us/library/t2zechd4.aspx
 */
#define ID_EXPERTS_ONOFF                    33020        // Toolbar: Experts on/off                    Ctrl+E

#define ID_CHART_REFRESH                    33324        // Chart:   Refresh
#define ID_CHART_STEPFORWARD                33197        //          One bar forward                      F12
#define ID_CHART_STEPBACKWARD               33198        //          One bar backward               Shift+F12
#define ID_CHART_EXPERT_PROPERTIES          33048        //          Expert properties dialog              F7
#define ID_CHART_OBJECTS_UNSELECTALL        35462        //          Objects: Unselect All

#define ID_WINDOW_NEWWINDOW                 57648        // Window:  New Window
#define ID_WINDOW_TILEWINDOWS               38259        //          Tile Windows                       Alt+R
#define ID_WINDOW_CASCADE                   57650        //          Cascade
#define ID_WINDOW_TILEHORIZONTALLY          57651        //          Tile Horizontally
#define ID_WINDOW_TILEVERTICALLY            57652        //          Tile Vertically
#define ID_WINDOW_ARRANGEICONS              57649        //          Arrange Icons

#define ID_MARKETWATCH_SYMBOLS              33171        // Market Watch: Symbols

#define ID_TESTER_TICK       ID_CHART_STEPFORWARD        // Tester:  Next Tick                            F12

#define WM_COMMAND                         0x0111


/**
 * Call the main menu item Charts->Objects->Unselect All.
 */
void Chart_Objects_UnselectAll() {
   int hWnd = WindowHandle(Symbol(), NULL);
   PostMessageW(hWnd, WM_COMMAND, ID_CHART_OBJECTS_UNSELECTALL, 0);
}


/**
 * Call the context menu item MarketWatch->Symbols.
 */
void MarketWatch_Symbols() {
   int hWnd = GetTerminalMainWindow();       // look in the code base for examples on how to resolve the main window handle from a chart handle
   PostMessageW(hWnd, WM_COMMAND, ID_MARKETWATCH_SYMBOLS, 0);
}
 
alphatrading:

Find the command id of the menu item or hotkey in question (e.g. with WInspector). Use PostMessage() to send chart specific commands (like CTRL-F5) to the chart window and chart unspecific comands (like F11) to the terminal main window. A few examples:



Thank you for your quick answer.

Could you help me how to use Winspector? I installed it, but the help file not working, and I couldn't find information on the web.

Or suggest some other way to get the Command ID

Thank you.

 

I just see this, and don't find the numbers.


winspector