MQL4 Screenshots - 0 bytes

 

Hello,

 

This seems to be a very odd problem but I have a line of code which takes a screenshot with a certain size.  The image file always gets created but sometimes the file size is 0 an others its the full image.  It's the same code that gets executed on the same mt4 instance so I can't figure out what would be creating the image with a file size of 0 and sometimes it working as expected.

 

Any ideas on how i can troubleshoot this or what the problem could be? 

 
With out code?
 
gooly:
With out code?

Yes because the code is the same line being executed over and over again.  

 

Here is the line of code:

WindowScreenShot(filename,640,480);

 

The problem is not the code because I know it's the same line over and over again.  The problem is that multiple screenshots over a quick succession of them  do not work or something else, this is what im trying to figure out.

 

Well I think you have given your answer yourself: too many in a short time.

You can buy a new and faster pc or at least a fast SSD harddisk - I think anything else won't help.

 
That was just me guessing, i don't know if this is the case.  How can i confirm that it is?
 
trader88888:
That was just me guessing, i don't know if this is the case.  How can i confirm that it is?
If i was to try and "slow" down the indicator by using sleep - it turns out I can't:    From the docs:  "The Sleep() function can't be called for custom indicators".  Any other ides on how this could be done so the file could be able to write?
 
Try using EA and let the EA take care of the screenshot. You can also use sleep() if you want or timer. Using script will not help much but you can do a lot more using EA.
 

When you want to start taking screenshots, call EventSetTimer() or EventSetMillisecondTimer().

When you want to stop taking shots, call EventKillTimer()

In OnTimer(), add you code for taking screenshots.

Example: if you set EventSetTimer(1), a screenshot will be taken every second until you kill the timer.

 
trader88888:
That was just me guessing, i don't know if this is the case.  How can i confirm that it is?

You can see how long it is blocked if you place right before and after your order WindowScreenShot(..) a GetTickCount():

   //--- Remember the initial value
   uint click=GetTickCount();
   WindowScreenShot(..)
   //--- Get the spent time in milliseconds
   click=GetTickCount()-click;
   Print("Blocked: ",(string)click," mSec");


 
honest_knave:

When you want to start taking screenshots, call EventSetTimer() or EventSetMillisecondTimer().

When you want to stop taking shots, call EventKillTimer()

In OnTimer(), add you code for taking screenshots.

Example: if you set EventSetTimer(1), a screenshot will be taken every second until you kill the timer.

So are you saying this? :  

 

EventSetTimer(1);
OnTimer()
{
WindowScreenShot(..)
}
EventKillTimer();

 

And then the screenshot would be taken once, and after it is the timer would be killed which would basically take a screenshot every 1 second? 

 
trader88888:   "The Sleep() function can't be called for custom indicators".
So don't sleep, wait for time to elapse.
OnCalc(...){
   :
   static datetime sleepUntil=0;
   if(TimeCurrent() >= sleepUntil){              // Sleep time expired.
      sleepUntil = TimeCurrent() + SleepSeconds; // Reset.
      :