Hi,
Am trying to program a Cntrl+J hotkey in MQL5. The following code does not work, as masking is not supported. Windows function GetAsyncKeyState() also does not work as apparently, MT5 is removing the event. Any suggestions / workaround?
Regards
PR
void OnChartEvent(const int id, // Event ID
const long& lparam, // Parameter of type long event
const double& dparam, // Parameter of type double event
const string& sparam // Parameter of type string events
) {
if (id == CHARTEVENT_KEYDOWN)
if (lparam == (VK_J | VK_CONTROL))
Print("Cntrl + J pressed", lparam);
}
piece of cake
if (id == CHARTEVENT_KEYDOWN) if (lparam == (17)) Print("Cntrl + J pressed"); }
;-)
piece of cake
;-)
joking - this is reserver for cross
just choose another key combination and print it out on console
joking - this is reserver for cross
just choose another key combination and print it out on console
Which cross? Cntrl+J press on a chart gives no action. Plus hardly any other Cntrl+<key> combination is free.
//+------------------------------------------------------------------+ //| charteventtest.mq5 | //| Copyright 2011, Investeo.pl | //| http://www.investeo.pl | //+------------------------------------------------------------------+ #property copyright "Copyright 2011, Investeo.pl" #property link "http://www.investeo.pl" #property version "1.00" //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ static bool ctrl_pressed = false; int OnInit() { //--- //--- return(0); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { //--- } //+------------------------------------------------------------------+ //| ChartEvent function | //+------------------------------------------------------------------+ void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam) { if (id == CHARTEVENT_KEYDOWN) if (ctrl_pressed == false && lparam == 17) ctrl_pressed = true; else if (ctrl_pressed == true) if (lparam == 74) { Print ("ctrl + j pressed"); ctrl_pressed = false; } }
works like a charm...
as for the cross - i was under Wine then, maybe this caused 'cross' display instead of the arrow. I checked my code above under Windows XP - it catches CTRL + J with no problem.
2011.11.21 21:06:22 charteventtest (AUDUSD,H1) ctrl + j pressed 2011.11.21 21:06:22 charteventtest (AUDUSD,H1) ctrl + j pressed 2011.11.21 21:06:21 charteventtest (AUDUSD,H1) ctrl + j pressed 2011.11.21 21:06:20 charteventtest (AUDUSD,H1) ctrl + j pressed
works like a charm...
as for the cross - i was under Wine then, maybe this caused 'cross' display instead of the arrow. I checked my code above under Windows XP - it catches CTRL + J with no problem.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
Am trying to program a Cntrl+J hotkey in MQL5. The following code does not work, as masking is not supported. Windows function GetAsyncKeyState() also does not work as apparently, MT5 is removing the event. Any suggestions / workaround?
Regards
PR
void OnChartEvent(const int id, // Event ID
const long& lparam, // Parameter of type long event
const double& dparam, // Parameter of type double event
const string& sparam // Parameter of type string events
) {
if (id == CHARTEVENT_KEYDOWN)
if (lparam == (VK_J | VK_CONTROL))
Print("Cntrl + J pressed", lparam);
}