Modification required for the codes of updating mt4 expert log file

 

I made these codes for updating the mt4 expert log file by ontimer function() of 1 second,... Now the codes working correctly but it open log file directory every second and then close that (like Flashing), through these my work is done which I was wanted by my expert but when I start expert then by opening/closing of this file directory I can't do anything else (like coding other things or some thing else work due to opening and closing of directory), If some one have some solution that how can I turn off this directory opening and closing while the updates should be not alter,... Then I appreciate to share such solution

My codes for updating the .log file is >>>..

#import "kernel32.dll"
int CreateFileW(string, uint, int, int, int, int, int);
int GetFileSize(int, int);
#import
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   EventSetTimer(1);
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
void OnTimer()
  {
   int hwnd = GetAncestor(WindowHandle(Symbol(),Period()),2);
   PostMessageA(hwnd,WM_COMMAND,35435,0);
   bool find=false;
   while(!find)
     {
      int LogHandle= FindIfDirOpened();
      if(LogHandle!=0)
        {
         PostMessageA(LogHandle, WM_CLOSE, 0, 0);
         find=true;
        }
      else
         if(find)
            break;
     }
  }
//+------------------------------------------------------------------+
int FindIfDirOpened()
  {
   string log = "logs",i;
   int handle = FindWindowW(i,log);
   return(handle);
  }
//+------------------------------------------------------------------+
Reason: