Skip to content

Commit 9ba86bb

Browse files
committed
add support for flag F_VK_ALL
1 parent 55fed6b commit 9ba86bb

File tree

6 files changed

+22
-37
lines changed

6 files changed

+22
-37
lines changed

mql40/include/rsf/expander/defines.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@
212212
#define F_VK_MENU 32 // ALT key
213213
#define F_VK_LWIN 64 // left Windows key
214214
#define F_VK_RWIN 128 // right Windows key
215+
#define F_VK_ALL 255 // F_VK_ESCAPE|F_VK_TAB|F_VK_CAPITAL|F_VK_SHIFT|F_VK_CONTROL|F_VK_MENU|F_VK_LWIN|F_VK_RWIN
215216

216217

217218
// order and operation types

mql40/include/rsf/stdfunctions.mqh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6243,7 +6243,7 @@ string ShellExecuteErrorDescription(int error) {
62436243
* @return bool - success status
62446244
*/
62456245
bool SendChartCommand(string cmdObject, string cmd, string mutex = "") {
6246-
if (!StringLen(mutex)) {
6246+
if (mutex == "") {
62476247
mutex = StringConcatenate("mutex.", cmdObject); // generate mutex if needed
62486248
}
62496249
if (!AquireLock(mutex)) return(false); // aquire write-lock

mql40/libraries/rsfMT4Expander.dll

0 Bytes
Binary file not shown.
Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* Chart.ToggleOpenOrders
33
*
4-
* Sends a command to an EA or the ChartInfos indicator in the current chart to toggle display of open orders.
4+
* Sends a command to EA or ChartInfos indicator in the current chart to toggle the display of open orders.
55
*/
66
#include <rsf/stddefines.mqh>
77
int __InitFlags[] = {INIT_NO_BARS_REQUIRED};
@@ -18,23 +18,15 @@ int __DeinitFlags[];
1818
int onStart() {
1919
if (__isTesting) Tester.Pause();
2020

21-
string command = "toggle-open-orders";
22-
string params = "";
23-
string modifiers = ",";
24-
if (IsVirtualKeyDown(VK_ESCAPE)) modifiers = modifiers +",VK_ESCAPE";
25-
if (IsVirtualKeyDown(VK_TAB)) modifiers = modifiers +",VK_TAB";
26-
if (IsVirtualKeyDown(VK_CAPITAL)) modifiers = modifiers +",VK_CAPITAL"; // CAPSLOCK key
27-
if (IsVirtualKeyDown(VK_SHIFT)) modifiers = modifiers +",VK_SHIFT";
28-
if (IsVirtualKeyDown(VK_CONTROL)) modifiers = modifiers +",VK_CONTROL";
29-
if (IsVirtualKeyDown(VK_MENU)) modifiers = modifiers +",VK_MENU"; // ALT key
30-
if (IsVirtualKeyDown(VK_LWIN)) modifiers = modifiers +",VK_LWIN";
31-
if (IsVirtualKeyDown(VK_RWIN)) modifiers = modifiers +",VK_RWIN";
32-
modifiers = StrRight(modifiers, -1);
21+
int virtKeys = GetPressedVirtualKeys(F_VK_ALL);
22+
string command = "toggle-open-orders::"+ virtKeys;
3323

34-
command = command +":"+ params +":"+ modifiers;
24+
bool isEA = (ObjectFind("EA.status") == 0);
25+
bool isShiftKey = (virtKeys & F_VK_SHIFT && 1);
26+
bool isWinKey = (virtKeys & F_VK_LWIN && 1);
3527

36-
// send to a running EA or the ChartInfos indicator
37-
if (ObjectFind("EA.status") == 0) SendChartCommand("EA.command", command);
38-
else SendChartCommand("ChartInfos.command", command);
28+
// send the command to an existing EA or the chart
29+
if (isEA && !isShiftKey && !isWinKey) SendChartCommand("EA.command", command);
30+
else SendChartCommand("ChartInfos.command", command);
3931
return(last_error);
4032
}
Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* Chart.ToggleTradeHistory
33
*
4-
* Sends a command to an EA or the ChartInfos indicator in the current chart to toggle display of the trade history.
4+
* Sends a command to EA or ChartInfos indicator in the current chart to toggle the display of closed trades.
55
*/
66
#include <rsf/stddefines.mqh>
77
int __InitFlags[] = {INIT_NO_BARS_REQUIRED};
@@ -19,23 +19,15 @@ int __DeinitFlags[];
1919
int onStart() {
2020
if (__isTesting) Tester.Pause();
2121

22-
string command = "toggle-trade-history";
23-
string params = "";
24-
string modifiers = ",";
25-
if (IsVirtualKeyDown(VK_ESCAPE)) modifiers = modifiers +",VK_ESCAPE";
26-
if (IsVirtualKeyDown(VK_TAB)) modifiers = modifiers +",VK_TAB";
27-
if (IsVirtualKeyDown(VK_CAPITAL)) modifiers = modifiers +",VK_CAPITAL"; // CAPSLOCK key
28-
if (IsVirtualKeyDown(VK_SHIFT)) modifiers = modifiers +",VK_SHIFT";
29-
if (IsVirtualKeyDown(VK_CONTROL)) modifiers = modifiers +",VK_CONTROL";
30-
if (IsVirtualKeyDown(VK_MENU)) modifiers = modifiers +",VK_MENU"; // ALT key
31-
if (IsVirtualKeyDown(VK_LWIN)) modifiers = modifiers +",VK_LWIN";
32-
if (IsVirtualKeyDown(VK_RWIN)) modifiers = modifiers +",VK_RWIN";
33-
modifiers = StrRight(modifiers, -1);
22+
int virtKeys = GetPressedVirtualKeys(F_VK_ALL);
23+
string command = "toggle-trade-history::"+ virtKeys;
3424

35-
command = command +":"+ params +":"+ modifiers;
25+
bool isEA = (ObjectFind("EA.status") == 0);
26+
bool isShiftKey = (virtKeys & F_VK_SHIFT && 1);
27+
bool isWinKey = (virtKeys & F_VK_LWIN && 1);
3628

37-
// send to a running EA or the ChartInfos indicator
38-
if (ObjectFind("EA.status") == 0) SendChartCommand("EA.command", command);
39-
else SendChartCommand("ChartInfos.command", command);
29+
// send the command to an existing EA or the chart
30+
if (isEA && !isShiftKey && !isWinKey) SendChartCommand("EA.command", command);
31+
else SendChartCommand("ChartInfos.command", command);
4032
return(last_error);
4133
}

mql40/scripts/Chart.ToggleUnitSize.mq4

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/**
22
* Chart.ToggleUnitSize
33
*
4-
* Sends a command to the ChartInfos indicator in the current chart to toggle location of the displayed unitsize
5-
* between "top" and "bottom".
4+
* Sends a command to the ChartInfos indicator in the current chart to toggle the "unitsize" location between
5+
* "top" and "bottom".
66
*/
77
#include <rsf/stddefines.mqh>
88
int __InitFlags[] = {INIT_NO_BARS_REQUIRED};

0 commit comments

Comments
 (0)