Image Uploader Scripting API
Classes | Functions
ScriptAPI Namespace Reference

Namespace containing functions and classes available in squirrel scripts. More...

Classes

class  CWebBrowser
 
class  Document
 
class  FileUploadTask
 
class  HtmlDocument
 
class  HtmlElement
 
class  Process
 The Process class is used to start external programs and to communicate with them.
More...
 
class  CRegExp
 
class  UploadTask
 
class  UrlShorteningTask
 

Functions

string AnsiToUtf8 (string str, int codepage)
 
string AskUserCaptcha (NetworkClient *nm, string url)
 Shows the captcha input dialog. More...
 
string Base64Decode (string data)
 
string Base64Encode (string data)
 
bool CopyFile (string source, string destination, bool overwrite)
 
bool CreateDirectory (string path_, unsigned int mode)
 
 DebugMessage (string msg, bool isResponseBody)
 Shows a dialog box with a diagnostic message.
 
bool DeleteFile (string utf8Filename)
 
string ExtractFileName (string path)
 
string ExtractFileNameNoExt (string fileName)
 
string ExtractFilePath (string fileName)
 
bool FileExists (string fileName)
 
string GetAppLanguage ()
 
string GetAppLanguageFile ()
 
string GetAppLocale ()
 
table GetAppVersion ()
 
string GetCurrentThreadId ()
 
string GetDeviceId ()
 
string GetDeviceName ()
 
string GetFileContents (string filename)
 
string GetFileExtension (string path)
 
string GetFileMimeType (string filename)
 
int GetFileSize (string filename)
 
double GetFileSizeDouble (string filename)
 
table GetImageInfo (string fileName)
 
string GetScriptsDirectory ()
 
string GetTempDirectory ()
 
string hmac_sha1 (string key, string data, bool base64)
 
string HtmlEntitiesDecode (string src)
 
object include (string filename)
 
string InputDialog (string text, string defaultValue)
 
string JsonEscapeString (string src)
 
string md5 (string data)
 Calculates the md5 hash of a string.
 
string md5_file (string filename)
 Calculates the md5 hash of a given file. More...
 
string MessageBox (string message, string title, string buttons, string type)
 
bool MoveFileOrFolder (string from, string to)
 
object ParseJSON (string json)
 
 print (string arg)
 
bool PutFileContents (string utf8Filename, string content)
 
int random ()
 
string sha1 (string data)
 
string sha1_file (string filename)
 
string sha1_file_prefix (string filename, string prefix, string postfix)
 
bool ShellOpenUrl (string url)
 
 sleep (int msec)
 
int system (string cmd)
 
string ToJSON (object obj)
 
string Translate (string key, string originalText)
 
string url_encode (string value)
 
string Utf8ToAnsi (string str, int codepage)
 

Detailed Description

Namespace containing functions and classes available in squirrel scripts.

Function Documentation

◆ AnsiToUtf8()

string ScriptAPI::AnsiToUtf8 ( string   str,
int  codepage 
)

Converts a string from ANSI encoding to UTF-8.

You can find the codepage number you need here:

https://raw.githubusercontent.com/zenden2k/image-uploader/master/Source/Core/3rdpart/CodePages.cpp

Available only in Windows.

◆ AskUserCaptcha()

string ScriptAPI::AskUserCaptcha ( NetworkClient nm,
string   url 
)

Shows the captcha input dialog.

nm - network manager, url - address of the image with captcha. The return value is the text entered by the user.

◆ CreateDirectory()

bool ScriptAPI::CreateDirectory ( string   path_,
unsigned int  mode 
)

Creates a directory (recursively). The mode parameter is ignored in Windows.

◆ ExtractFileNameNoExt()

string ScriptAPI::ExtractFileNameNoExt ( string   fileName)

Extract the file name without extension from the path.

Since
1.3.0

◆ ExtractFilePath()

string ScriptAPI::ExtractFilePath ( string   fileName)

Extract directory name from path.

Since
1.3.0

◆ FileExists()

bool ScriptAPI::FileExists ( string   fileName)

Checks if a file exists.

Since
1.3.0

◆ GetAppLanguage()

string ScriptAPI::GetAppLanguage ( )

Returns application's current language. For example : "en", "ru".

◆ GetAppLanguageFile()

string ScriptAPI::GetAppLanguageFile ( )

Returns name of the application's current language file (without .lng extension). For example: "English", "Russian".

Since
1.3.1

◆ GetAppLocale()

string ScriptAPI::GetAppLocale ( )

Returns application's current locale. For example : "en_US", "ru_RU".

◆ GetAppVersion()

table ScriptAPI::GetAppVersion ( )

Returns a table containing information about application's version. For example:

{
Major = 1,
Minor = 3,
Release = 1,
Build = 4240,
Gui = true
}
Since
1.3.1

◆ GetCurrentThreadId()

string ScriptAPI::GetCurrentThreadId ( )

Retrieves the thread identifier of the calling thread.

◆ GetFileContents()

string ScriptAPI::GetFileContents ( string   filename)
Since
1.3.0

◆ GetFileMimeType()

string ScriptAPI::GetFileMimeType ( string   filename)

Returns the MIME file type (for example, "text / html"), analyzing the contents of the file. File must exist. (in Windows, the FindMimeFromData function is used. In unix, the command 'file -b –mime-type' is used.).

◆ GetFileSize()

int ScriptAPI::GetFileSize ( string   filename)

Returns the size of the file in bytes.

Since
1.3.0

◆ GetFileSizeDouble()

double ScriptAPI::GetFileSizeDouble ( string   filename)

Returns the size of the file in bytes (for files greater than 2 GB).

Since
1.3.0
Deprecated:

◆ GetImageInfo()

table ScriptAPI::GetImageInfo ( string   fileName)

Returns a table containing information about image. For example:

{
Width = 640,
Height = 480
}
Since
1.3.2.4616

◆ GetScriptsDirectory()

string ScriptAPI::GetScriptsDirectory ( )

Returns path to squirrel scripts directory.

Since
1.3.1

◆ GetTempDirectory()

string ScriptAPI::GetTempDirectory ( )

Returns the directory for temporary files

Since
1.3.0

◆ hmac_sha1()

string ScriptAPI::hmac_sha1 ( string   key,
string   data,
bool  base64 
)

Generate a keyed hash value using the HMAC method and sha1 hashing algorythm

Parameters
dataMessage to be hashed.
keyShared secret key used for generating the HMAC variant of the message digest.
base64Generate in base64 format

◆ include()

object ScriptAPI::include ( string   filename)

Includes and runs the script from file. filename should be relative to the scripts root directory.

◆ InputDialog()

string ScriptAPI::InputDialog ( string   text,
string   defaultValue 
)

Displays a prompt in a dialog box, waits for the user to input text or click a button, and returns a String containing the contents of the text box.

Parameters
defaultValueDefault text displayed in text box

◆ JsonEscapeString()

string ScriptAPI::JsonEscapeString ( string   src)

Escapes a string for use in JSON. Returns a string with quotes.

Deprecated:
Instead, use the ToJSON function.

◆ md5_file()

string ScriptAPI::md5_file ( string   filename)

Calculates the md5 hash of a given file.

Since
1.2.7.4176

◆ MessageBox()

string ScriptAPI::MessageBox ( string   message,
string   title,
string   buttons,
string   type 
)

Shows a dialog box with a message

buttons possible values: OK, YES_NO, YES_NO_CANCEL, ABORT_RETRY_IGNORE,CANCEL_TRY_CONTINUE, OK_CANCEL, RETRY_CANCEL

type possible values: EXCLAMATION, WARNING, INFORMATION, QUESTION, ERROR

Returns
Title of the clicked button ( ABORT,CANCEL, CONTINUE, IGNORE, YES, NO, OK, TRY).

◆ MoveFileOrFolder()

bool ScriptAPI::MoveFileOrFolder ( string   from,
string   to 
)

Renames/moves a file or folder.

Since
1.3.0

◆ ParseJSON()

object ScriptAPI::ParseJSON ( string   json)

Converts text containing a JSON document, into a table (associative container made in the form of key / value pairs) or an array. For example, the original JSON document:

{
"result": {
"success": true,
"links": [
{
"href": "http://example.com/thumb.jpg"
},
{
"href": "http://example.com/image.jpg"
}
]
}
}

Squirrel script:

local t = ParseJSON(text);
print(t.result.links[1].href); // will print "http://example.com/image.jpg"
object ParseJSON(string json)
print(string arg)
Returns
In case of error function retuns null.
Since
1.3.0

◆ print()

ScriptAPI::print ( string  arg)

Standard squirrel function for writing text to standard output. It's results can be seen in the log window.

◆ PutFileContents()

bool ScriptAPI::PutFileContents ( string   utf8Filename,
string   content 
)

Write data to a file

Since
1.3.0

◆ random()

int ScriptAPI::random ( )

Returns a random number.

◆ sha1()

string ScriptAPI::sha1 ( string   data)

Calculates the sha1-hash of a given string

Since
1.2.7.4176

◆ sha1_file()

string ScriptAPI::sha1_file ( string   filename)

Calculates the sha1-hash of a given file

Since
1.2.7.4176

◆ sha1_file_prefix()

string ScriptAPI::sha1_file_prefix ( string   filename,
string   prefix,
string   postfix 
)

Calculates the sha1-hash of a given file, prepeding file with prefix and adding postfix at the end while calculating hash

Since
1.3.3

◆ ShellOpenUrl()

bool ScriptAPI::ShellOpenUrl ( string   url)

Opens a URL/file in a standard browser/associated application.

Since
1.2.9.4185

◆ sleep()

ScriptAPI::sleep ( int  msec)

The script falls asleep for the specified number of milliseconds.

◆ system()

int ScriptAPI::system ( string  cmd)

Execute shell command. Parameter cmd is using default operating system locale (so it won't work with utf-8 strings on windows). Use Process class instead

◆ Translate()

string ScriptAPI::Translate ( string   key,
string   originalText 
)

Returns text translated into the currently selected language. Every user-visible string in the script must be wrapped into this function. Translating scripts into different languages

◆ url_encode()

string ScriptAPI::url_encode ( string   value)

URL-encodes string. This function is convenient when encoding a string to be used in a query part of a URL.

Use NetworkClient's nm.urlEncode() when possible instead.

◆ Utf8ToAnsi()

string ScriptAPI::Utf8ToAnsi ( string   str,
int  codepage 
)

Converts a string from ANSI encoding to UTF-8.

You can find the codepage number you need here:

https://raw.githubusercontent.com/zenden2k/image-uploader/master/Source/Core/3rdpart/CodePages.cpp

Available only in Windows.