tools
A collection of handy miscellaneous tools for Lua development.
- Functions - API calls offered directly by the extension
- Methods - API calls which can only be made on an object returned by a constructor
Signature | cp.tools.camelCase(str) -> string |
Type | Function |
Description | Converts the supplied string to camelcase. |
Parameters |
|
Returns |
|
Signature | cp.tools.centre(frame) -> hs.geometry point |
Type | Function |
Description | Gets the centre point of a frame. |
Parameters |
|
Returns |
|
Signature | cp.tools.cleanupButtonText(value) -> string |
Type | Function |
Description | Removes the … symbol and multiple >'s from a string. |
Parameters |
|
Returns |
|
| Signature |
cp.tools.contentsInsideBrackets(value) -> string | nil
| | -----------------------------------------------------|---------------------------------------------------------------------------------------------------------| | Type | Function | | Description | Gets the contents of any text inside the first bracket set. | | Parameters |- value - The string to process
| | Returns |
- The contents as a string or
nil
|
Signature | cp.tools.convertSingleHexStringToDecimalString(hex) -> string |
Type | Function |
Description | Converts a single hex string (i.e. "3") to a binary string (i.e. "0011") |
Parameters |
|
Returns |
|
Signature | cp.tools.dirFiles(path) -> table |
Type | Function |
Description | Gets all the files in a directory |
Parameters |
|
Returns |
|
Signature | cp.tools.doesDirectoryExist(path) -> boolean |
Type | Function |
Description | Returns whether or not a directory exists. |
Parameters |
|
Returns |
|
Signature | cp.tools.doesFileExist(path) -> boolean |
Type | Function |
Description | Returns whether or not a file exists. |
Parameters |
|
Returns |
|
Signature | cp.tools.doubleLeftClick(point[, delay]) -> none |
Type | Function |
Description | Performs a Left Mouse Double Click. |
Parameters |
|
Returns |
|
Signature | cp.tools.endsWith(str, ending) -> boolean |
Type | Function |
Description | Checks to see if str has the same ending as ending . |
Parameters |
|
Returns |
|
| Signature |
cp.tools.ensureDirectoryExists(rootPath, ...) -> string | nil
| | -----------------------------------------------------|---------------------------------------------------------------------------------------------------------| | Type | Function | | Description | Ensures all steps on a provided path exist. If not, attempts to create them. | | Parameters |rootPath
- The root path...
- The list of path steps to create
| | Returns |
- The full path, if it exists, or
nil
if unable to create the directory for some reason.
|
Signature | cp.tools.exactMatch(value, pattern, plain) -> boolean |
Type | Function |
Description | Compares two strings to see if they're an exact match. |
Parameters |
|
Returns |
|
Signature | cp.tools.executeWithAdministratorPrivileges(input[, stopOnError]) -> boolean or string |
Type | Function |
Description | Executes a single or multiple shell commands with Administrator Privileges. |
Parameters |
|
Returns |
|
Signature | cp.tools.findCommonWordWithinTwoStrings(a, b) -> string |
Type | Function |
Description | Finds a common word within two strings. |
Parameters |
|
Returns |
|
Signature | cp.tools.firstToUpper(str) -> string |
Type | Function |
Description | Makes the first letter of a string uppercase. |
Parameters |
|
Returns |
|
Signature | cp.tools.getEmail() -> string |
Type | Function |
Description | Returns the current users Email, otherwise an empty string. |
Parameters |
|
Returns |
|
Signature | cp.tools.getExternalDevices() -> string |
Type | Function |
Description | Returns a string of USB & Thunderbolt Devices. |
Parameters |
|
Returns |
|
Signature | cp.tools.getFileExtensionFromPath(input) -> string |
Type | Function |
Description | Gets the file extension from a path. |
Parameters |
|
Returns |
|
Signature | cp.tools.getFilenameFromPath(input[, removeExtension]) -> string |
Type | Function |
Description | Gets the filename component of a path. |
Parameters |
|
Returns |
|
Signature | cp.tools.getFullname() -> string |
Type | Function |
Description | Returns the current users Full Name, otherwise an empty string. |
Parameters |
|
Returns |
|
Signature | cp.tools.getKeysSortedByValue(tbl, sortFunction) -> table |
Type | Function |
Description | Sorts table keys by a value |
Parameters |
|
Returns |
|
Signature | cp.tools.getmacOSVersion() -> string |
Type | Function |
Description | Returns the macOS Version in the format that Apple's Feedback Form expects. |
Parameters |
|
Returns |
|
Signature | cp.tools.getModelName() -> string |
Type | Function |
Description | Returns Model Name of Hardware. |
Parameters |
|
Returns |
|
Signature | cp.tools.getRAMSize() -> string |
Type | Function |
Description | Returns RAM Size in a format Apple's Feedback form expects. |
Parameters |
|
Returns |
|
Signature | cp.tools.getScreenshotsAsBase64() -> table |
Type | Function |
Description | Captures all available screens and saves them as base64 encodes in a table. |
Parameters |
|
Returns |
|
Signature | cp.tools.getThunderboltDevices() -> string |
Type | Function |
Description |