when I press the button named "test", the key-combo ALT+Q should be simulated and a small script which has the MT4 hot key ALT-Q should be executed.
Pretty easy but it doesn't work. If I use in-built-hot keys like ALT-R for the window-arrangement or ALT-M for the chat, it works perfect. But it never works when the simulated key-combo should run a script which has the corresponding hot key. When I press ALT-Q manually the script is executed without any problems. But why doesn't it work with my code?
#property strict#property indicator_chart_window#import "user32.dll"void keybd_event(int bVk, int bScan, int dwFlags,int dwExtraInfo);
#import
#define REL 0x0002#define ALT 0x12#define VK_Q 0x51//+------------------------------------------------------------------+//| Custom indicator initialization function |//+------------------------------------------------------------------+intOnInit()
{
//--- indicator buffers mapping//---return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+//| Custom indicator iteration function |//+------------------------------------------------------------------+intOnCalculate(constint rates_total,
constint prev_calculated,
constdatetime &time[],
constdouble &open[],
constdouble &high[],
constdouble &low[],
constdouble &close[],
constlong &tick_volume[],
constlong &volume[],
constint &spread[])
{
//---//--- return value of prev_calculated for next callreturn(rates_total);
}
//+------------------------------------------------------------------+//| ChartEvent function |//+------------------------------------------------------------------+voidOnChartEvent(constint id,
constlong &lparam,
constdouble &dparam,
conststring &sparam)
{
//---if (id==CHARTEVENT_OBJECT_CLICK) {
if (sparam=="test") {
keybd_event(ALT, 0, 0, 0);
keybd_event(VK_Q, 0, 0, 0);
keybd_event(ALT, 0, REL, 0);
keybd_event(VK_Q, 0, REL, 0);
}
}
}
Hello coders,
when I press the button named "test", the key-combo ALT+Q should be simulated and a small script which has the MT4 hot key ALT-Q should be executed.
Pretty easy but it doesn't work. If I use in-built-hot keys like ALT-R for the window-arrangement or ALT-M for the chat, it works perfect. But it never works when the simulated key-combo should run a script which has the corresponding hot key. When I press ALT-Q manually the script is executed without any problems. But why doesn't it work with my code?