bool TakeScreenShot=WindowScreenShot(filename,ChartWidth,ChartHeight);
Where do you test the return code and the error?
What are Function return values ? How do I use them ? - MQL4 and MetaTrader 4 - MQL4 programming forum
Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articlesstring filename= folder+"\\"+year+"\\"+month+"\\"+day+" "+date+"\\"+time+".gif";
Are you sure there is a folder "<data folder>\MQL4\files\<folder>\<year>\<month>\<day> <date>\"
Updated the code
if(!WindowScreenShot(filename,ChartWidth,ChartHeight)) Print ("Failed to take "+folder+" ",GetLastError());
Got a 5004 error
ERR_FILE_CANNOT_OPEN |
Yet the folder is being created in windows - refer to original post
Yet the folder is being created in windows - refer to original post
Your code is trying to create a filename such as 12:18:43.gif. Colons (:) in filenames are not permitted by Windows.
Thank you JC. Made the changes and all working now.
Here is my code changes although I will be altering to get a more attractive file name.
date = IntegerToString(TimeDay(TimeCurrent())); hour = IntegerToString(TimeHour(TimeCurrent())); minute = IntegerToString(TimeMinute(TimeCurrent())); string filename= folder+"\\"+Symbol()+"\\"+year+"\\"+month+"\\"+day+" "+date+"\\"+Symbol()+" "+day+" "+date+" "+month+" "+year+" "+hour+"_"+minute+".gif"; int ChartWidth = guiGetChartWidth(hwnd); int ChartHeight= guiGetChartHeight(hwnd); if(!WindowScreenShot(filename,ChartWidth,ChartHeight)) Print ("Failed to take "+folder+" ",GetLastError()); else Print(folder+" successfully taken");
Here is my code changes although I will be altering to get a more attractive file name.
You could also do something like the following:
StringReplace(time, ":", "_");
By the way, guiGetChartWidth(hwnd) looks like it may turn into a Windows API call to get the chart dimensions, which is no longer necessary since MQL added ChartGetInteger(0, CHART_WIDTH_IN_PIXELS)
By the way, guiGetChartWidth(hwnd) looks like it may turn into a Windows API call to get the chart dimensions, which is no longer necessary since MQL added ChartGetInteger(0, CHART_WIDTH_IN_PIXELS)
I'm building a trading panel with the MT4GUI interface from the good people at fx1.net. I like their buttons and check boxes. But the big advantage is it produces tics allowing me to place manual trades using strategy tester. The guiGetChartWidth is one of their commands.
Do you think there are any pros or cons to using a third party software command over and "in-house" command? (if I have used the word "in-house correctly, forgive me if I haven't.)
Do you think there are any pros or cons to using a third party software command over and "in-house" command? (if I have used the word "in-house correctly, forgive me if I haven't.)
Given the context, no, no pros or cons.
ChartGetInteger() avoids the need to turn on "Allow DLL imports", which prevents you selling things through the MQL Market or using MT4's built-in pseudo-VPS hosting. But neither of those sounds applicable here, and you will be using lots of other features which require "Allow DLL imports" to be turned on.
Many thanks for taking the time to answer my questions JC. Most appreciated.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Good morning all.
I use the this code to take screenshot yet when I open the file there are no picture. Can somebody identify my dumb dumb. Many thanks in advance.