How to get Terminal to gain focus via EA?


Hi all,

i would like to have my EA cause the Metatrader 5 Terminal to gain focus when a new Bar is started.

Do regular work on my computer and it would be fantastic if the Terminal could be brought to the top, to gain my attention fully.

Have been using a sound alert and flashing backgroung color (which i can see, as my work apps are not fully maximized) at the start of a new bar, but have gotten so used to these alerts that i sometimes find myself focussed on my computer work, and not realize that an alert has taken place.

Frog in slowly warming water syndrome!

So have missed a couple of good setups in the past weeks...

Have tried to simulate a keyboard shortcut "Ctrl"+"Q", which when used manually, brings my Terminal to the front. I run MT5 in linux (under wine), where i have set the shortcut for the Terminal.

#import "user32.dll"
    void keybd_event(int bVk, int bScan, int dwFlags,int dwExtraInfo);
#define  VK_Q 0x51               // Q
#define  VK_LCONTROL 0xA2        // left Ctrl 
#define  KEYEVENTF_KEYUP 0x0003  // key up

and using

keybd_event(0xA2, 0, 1, 0);      // press left Ctrl
keybd_event(0x51, 0, 0, 0);      // press Q
keybd_event(0xA2, 0, 0x0003, 0); // release left Ctrl
keybd_event(0x51, 0, 0x0003, 0); // release Q

in my EA at the start of new Bar.

However, this only works when the Terminal already has focus.Therby defeating the object.

For example, if i use "Alt"+"B", it will bring up the Market Depth Window on the start of a new Bar. But only when the Terminal already has focus. Should i have another app open with focus, the EA will not open the Market Deph Window. If i have the Meta Editor open with focus, it will open the "Bearbeiten" (Edit) dropdown menu. So basically the


works on the app that has focus, but not on the operating system level.

Any ideas on how this could be accomplished?


Wir sprechen hier eigentlich deutsch.

Aber vielleicht genügt ja ein Play(".."). Ertönt die Musik, musst Du halt mit der Maus 'rüberklicken.

Grund der Beschwerde: