Kodi Community Forum

Full Version: Are there "TakeScreenshot" parameters?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello!
I'm trying to make an addon that names screenshots based on the content being played. IE "ShowName SxxExx Screenshot ###.jpg"

So first I'm trying to figure out how to pass on the filename I want to xbmc.executebuiltin("TakeScreenshot").
In http://kodi.wiki/view/list_of_built-in_functions it says that "TakeScreenshot" doesn't take any parameters so I guess the save path for the screenshot is stored somewhere in the settings.

I would be very grateful if someone would point me to where those settings are and tell me how to manipulate them.

Thanks.
the filename is harcoded in the kodi source-code.

unless you want to modify the source-code and compile kodi yourself, there's nothing you can do to change it.


edit: the above is incorrect, see below
(2016-06-03, 17:48)ronie Wrote: [ -> ]the filename is harcoded in the kodi source-code.

unless you want to modify the source-code and compile kodi yourself, there's nothing you can do to change it.

Thanks.
What about the file path?
it's stored in guisettings.xml
You could do it via code.

Retrieve (via json) the current folder name, change it to a temporary folder (again via json), take the screenshot, rename the file, move it to the original screenshot folder, reset the screenshot folder back to the original. Optionally, delete the temporary folder.


Sent from my iPhone
PIL could perhaps take a screen shot with some more options?
http://www.varesano.net/blog/fabio/captu...%20windows
Apologies, however, whilst I don't mean to contradict anyone, there is a way to add parameters to the TakeScreenshot builtin function. I successfully tested this using Kodi.Krypton, however, I do remember seeing this some time ago...

PHP Code:
TakeScreenshot(filePathAndNamePNG

Taken from: GUIBuiltins

PHP Code:
/*! \brief Take a screenshot.
 *  \param params The parameters.
 *  \details params[0] = URL to save file to. Blank to use default.
 *           params[1] = "sync" to run synchronously (optional).
 */
static int Screenshot(const std::vector<std::string>& params)
{
  if (!
params.empty())
  {
    
// get the parameters
    
std::string strSaveToPath params[0];
    
bool sync false;
    if (
params.size() >= 2)
      
sync StringUtils::EqualsNoCase(params[1], "sync");

    if (!
strSaveToPath.empty())
    {
      if (
XFILE::CDirectory::Exists(strSaveToPath))
      {
        
std::string file CUtil::GetNextFilename(URIUtils::AddFileToFolder(strSaveToPath"screenshot%03d.png"), 999);

        if (!
file.empty())
        {
          
CScreenShot::TakeScreenshot(filesync);
        }
        else
        {
          
CLog::Log(LOGWARNING"Too many screen shots or invalid folder %s"strSaveToPath.c_str());
        }
      }
      else
        
CScreenShot::TakeScreenshot(strSaveToPathsync);
    }
  }
  else
    
CScreenShot::TakeScreenshot();

  return 
0;

thx! i'll update the wiki with this info.
(2016-06-08, 08:56)ronie Wrote: [ -> ]thx! i'll update the wiki with this info.

you're welcome... i took a look at the wiki and you, may, have missed a closing bracket:

current:
PHP Code:
TakeScreenshot([filenameandpath,sync

should be:
PHP Code:
TakeScreenshot([filenameandpath,sync]) 

also, it may be worth mentioning that the supplied file extension must be "PNG"; i - out of curiosity - tried "bmp, jpg", but got an error... something about format not being supported.

thnx!
fixed, thx!