vdemydiuk / mtapi

MetaTrader API (terminal bridge)
http://mtapi4.net/
MIT License
514 stars 277 forks source link

Connect to MT5 by process #180

Open educawendellsouza opened 4 years ago

educawendellsouza commented 4 years ago

Dears, good morning. Initially, I'm trying to make some way of creating a program (using MTa dlls) possible to rotate MetaTrader5 profiles. The program basically has to send a CTRL + F5 from time to time to MT5, but I'm trying to make mtConnection( ) recognize the connection (if any? lol) to Process( ). Is there any way I can get MT5 to recognize my program commands and send CTRL + F5 from time to time? Note: In Process( ) I configure which path of MT5 (Process.StartInfo.FileName) should receive the command. If anyone can help me, I appreciate it and it is good that it facilitates us not to lose more entries, just by rotating the parities that will be analyzed.

vdemydiuk commented 4 years ago

Hi, Hotkey CTRL + F5 is using to switch profile. MtApi (MT5) does not have functionality to change profile, and I am not sure that it will be good for the API. After switching profile it can have another charts without MtApi.ex4 expert and clients side will lose connection with terminal. I think you need to create another module that will monitor the MT process and will send CTRL + F5 message to it for switching profile. If you need help in it please let me know.

cod3r85 commented 3 years ago

@educawendellsouza ... if you are developing for Windows Environment you could use the .net framework SendKeys.

First you would need to identify which WINDOW (not process) to send the key command to.

Examples and Discussion: https://social.msdn.microsoft.com/Forums/vstudio/en-US/4e60ee67-7907-4374-ae82-a258212d4597/directly-sending-keystrokes-to-another-process-via-hooking?forum=vbgeneral