I have met the same problem too. So i come to give my thanks to all the authors above!
Besides, i have made a little adjustment to the EA log refreshing codes. complete version is below:
this method may not be the best, though, it is practicable.
Yes, I want to place order reading log file.
Like,, if MT4 journal shows indicator buy signal, I want to order because some indicator has no buffers.
Getting the directory handle does not work smoothly
Because the window title is not logs
Findwindow requires the window title to correspond exactly
So I modified this part as follows
Close by looking up the class name of the window, although this will also close other directory windows
In addition, I made changes to while to avoid an infinite loop.
After not finding it for a period of time, continue to open the directory next time.
int GetAncestor(int hWnd, int gaFlags);
int hwnd = GetAncestor(WindowHandle(Symbol(),Period()),2); // find the Terminal handle no.
PostMessageW(hwnd,WM_COMMAND ,33101,0); // open the folder contains the log files
int LogHandle= FindIfDirOpened();
PostMessageW(FindIfDirOpened(), WM_CLOSE, 0, 0); //close the folder
// string log = "logs";
int handle = FindWindowW(classname ,NULL);
The latest progress, I found a better way with spy++
Use the right-click menu to view instead of open, which will open the log detail window inside MT4
This operation will also update the log file.
The advantage of this is the view window is a sub-window belonging to MT4 and can be executed in the background.
The only thing I need to solve is to find the child window command using FindWindowEx instead of FindWindowW.
However, in actual use, I encountered another problem. My imported FindWindowEx reported an error at runtime:
Unresolved import function call
Cannot find 'FindWindowEX' in 'user32.dll'
Here is my code:
int GetAncestor( int hWnd, int gaFlags);
int FindWindowEx( int hwndParent, int hwndChild, string lpszClass, string lpszTitle);
string log = "\\Logs" ;
//string classname="CabinetWClass"; // use for open log folder
int handle = FindWindowEx(hwndParent, 0 , i , log );
Can someone explain why?
After solving it, I can send the complete code.
Because it is not working properly now, so I didn’t send it all.
But the method is ok, I have implemented it in C#, the effect is very good.