### File and Folder Object Examples Source: https://extendscript.docsforadobe.dev/print_page Provides example functions for reading from and writing to files in the user's application data folder, along with a demonstration of their usage. ```javascript /** * Reads data from a given file in userdata folder * @param {string} filename Filename, with extension * @return {string} File contents, if file exists */ function readUserDataFromFile(filename) { var userDataFolder = Folder.userData; var filepath = userDataFolder.fullName + "/" + filename; var file = new File(filepath); file.encoding = "UTF-8"; if (!file.exists) { throw "Could not find file '" + String(file.fsName); } file.open(); var contents = file.read(); file.close(); return contents; } /** * Writes data to a given file in userdata folder * @param {string} filename Filename, with extension * @param {string} data Data to write */ function writeUserDataToFile(filename, data) { var userDataFolder = Folder.userData; var filepath = userDataFolder.fullName + "/" + filename; var file = new File(filepath); file.encoding = "UTF-8"; file.open("w"); var success = file.write(data); file.close(); if (!success) { throw "Could not write to file '" + String(file.fsName); } } try { var filename = "myFile.txt"; var contents = "Hello world!"; writeUserDataToFile(filename, contents); var readData = readUserDataFromFile(filename); alert("File Contents: '" + String(readData) + "'"); } catch (e) { alert(e); } ``` -------------------------------- ### Absolute Path Example Source: https://extendscript.docsforadobe.dev/print_page An example of an absolute path in URI notation for a file. ```plaintext /dir1/dir2/mydir/myFile.jsx ``` -------------------------------- ### Define function signature examples Source: https://extendscript.docsforadobe.dev/print_page Example of mapping C function prototypes to signature strings. ```C One (Integer a, String b); Two (); ``` -------------------------------- ### BridgeTalk.getTargets() Example Source: https://extendscript.docsforadobe.dev/interapplication-communication/bridgetalk-class Demonstrates how to use BridgeTalk.getTargets() with different parameters to retrieve application targets based on version and locale. ```APIDOC ## BridgeTalk.getTargets() Example ### Description Provides examples of using `BridgeTalk.getTargets()` to retrieve application targets based on version and locale. ### Examples ```javascript // Assuming installed applications include Photoshop CS3 10.0 en_US, Photoshop CS4 11.0 en_us, and Illustrator CS4 14.0 de_de // Get all targets BridgeTalk.getTargets(); => ["photoshop", "illustrator"] // Get targets for a specific version BridgeTalk.getTargets( "10.0" ); => ["photoshop-10.0"] // Get targets for the latest installed version of each application BridgeTalk.getTargets( null ); => ["photoshop-11.0", "illustrator-14.0"] // Get targets for a specific version and locale BridgeTalk.getTargets( null, "en_US" ); => ["photoshop-10.0-en_US", "photoshop-11.0-en_US"] // Get all installed targets with version and locale BridgeTalk.getTargets( null, null ); => ["photoshop-10.0-en_US", "photoshop-11.0-en_us", "illustrator-14.0-de_de"] ``` ``` -------------------------------- ### Relative Path Examples Source: https://extendscript.docsforadobe.dev/print_page Illustrates various relative path notations for locating files in relation to the current directory. ```plaintext myFile.jsx ``` ```plaintext ./myFile.jsx ``` ```plaintext ../myFile.jsx ``` ```plaintext ../../myFile.jsx ``` ```plaintext ../dir1/myFile.jsx ``` -------------------------------- ### Define XML Namespace Example Source: https://extendscript.docsforadobe.dev/integrating-xml/xml-object-reference Example of an XML namespace declaration showing the prefix and URI association. ```xml ``` -------------------------------- ### Check for target application installation Source: https://extendscript.docsforadobe.dev/interapplication-communication/communicating-through-messages Use BridgeTalk.getSpecifier to verify if a specific version of an application is installed before attempting to send a message. ```javascript var targetApp = BridgeTalk.getSpecifier( "bridge-3.0"); if( targetApp ) { // construct and send message } ``` -------------------------------- ### Complete BridgeTalk messaging workflow Source: https://extendscript.docsforadobe.dev/interapplication-communication/communicating-through-messages A full example demonstrating target specification, message construction, callback definition, and asynchronous transmission. ```javascript // script to be executed in Photoshop CS4 #target "photoshop-11.0" // check that the target app is installed var targetApp = BridgeTalk.getSpecifier( "bridge-3.0"); if( targetApp ) { // construct a message object var bt = new BridgeTalk; // the message is intended for Adobe Bridge CS4 bt.target = targetApp; // the script to evaluate is contained in a string in the "body" property bt.body = "new Document('C:\\BridgeScripts');app.document.target.children.length;" // define result handler callback bt.onResult = function(returnBtObj) { processResult(returnBtObj.body); } //fn defined elsewhere // send the message asynchronously bt.send(); } ``` -------------------------------- ### MessageSendingToInDesign.jsx Example Source: https://extendscript.docsforadobe.dev/interapplication-communication/messaging-framework-api-reference Shows how to send a message to Adobe InDesign using BridgeTalk. This example is included in the Adobe ExtendScript SDK. ```javascript // MessageSendingToInDesign.jsx // Sends a message to InDesign through BridgeTalk. ``` -------------------------------- ### Loading a Library with ExternalObject Constructor Source: https://extendscript.docsforadobe.dev/print_page Example of instantiating an ExternalObject by specifying the library file. The 'lib:' prefix is case-sensitive and marks dynamic libraries. ```javascript var mylib = new ExternalObject( "lib:myLibrary" ); ``` -------------------------------- ### Define XML structure Source: https://extendscript.docsforadobe.dev/integrating-xml/the-xml-object Example of a minimal XML structure used for demonstration. ```xml ``` -------------------------------- ### ScriptUI Code Examples Source: https://extendscript.docsforadobe.dev/print_page Sample code distributed with the Adobe ExtendScript SDK demonstrates different ways of building and populating a ScriptUI dialog. ```APIDOC # Code examples for ScriptUI The sample code distributed with the Adobe ExtendScript SDK includes code examples that specifically demonstrate different ways of building and populating a ScriptUI dialog. Building ScriptUI dialogs | Description ---|--- SnpCreateDialog.jsx | Creates a very simple, modeless dialog (a palette) with OK and Cancel button behavior. SnpCreateUIAddMethod.jsx | Shows how to add controls to a dialog using the add method. SnpCreateUIResourceSpec.jsx | Shows how to define a resource string that creates the control hierarchy in a dialog. SnpCreateTreeView.jsx | Shows how to create a hierarchical list with subitems. SnpCreateProgressBar.jsx | Shows how to create, initialize, and update a progress bar. SnpCreateSlider.jsx | Shows how to create and handle input from a slider control. UsingFlashPlayer.jsx | Shows how to create a Flash® Player, and use it to load a play back a movie defined in an SWF file. ActionScriptDemo.jsx | Shows how to communicate between the Adobe application scripting environment and the ActionScript™ scripting environment of the Flash Player. ColorSelector.jsx | Shows how to use the graphics objects to change colors in a window. ColorPicker.jsx | A more complex version of the color-selection dialog shows how to use additional graphics objects, including fonts and paths. SnpAlignElements.jsx | Shows how to align elements along two dimensions in order to control the relative positions of controls within rows and columns. SnpCreateDynamicScriptUI.jsx | Shows how to use automatic layout, switching component layout between "row" and "stack" orientation. AlertBoxBuilder1.jsx | Shows a way to use resource specifications. Uses the add() method to build a dialog that collects values from the user, and creates a resource string from those values. Saves the string to a file, then uses it to build a new dialog. See Using resource strings. AlertBoxBuilder2.jsx | Shows another way to use a resource specification, building the same user-input dialog itself from a resource string. See Using resource strings. SnpCustomLayoutManager.jsx | Shows how to create a customized layout manager. See Custom layout-manager example. ``` -------------------------------- ### Connect to a Web Server as a Client Source: https://extendscript.docsforadobe.dev/external-communication/socket-object Establishes a TCP connection to a remote server and performs a basic HTTP GET request. ```javascript var reply = ""; var conn = new Socket; // access Adobe's home page if (conn.open ("www.adobe.com:80")) { // send a HTTP GET request conn.write ("GET /index.html HTTP/1.0\n\n"); // and read the server's reply reply = conn.read(999999); conn.close(); } ``` -------------------------------- ### Interapplication Messaging Examples Source: https://extendscript.docsforadobe.dev/interapplication-communication/messaging-framework-api-reference The Adobe ExtendScript SDK includes sample code demonstrating various interapplication messaging scenarios using BridgeTalk. ```APIDOC ## Interapplication Messaging Examples ### Description These examples, found in the Adobe ExtendScript SDK, demonstrate how to use the messaging API for various interapplication communication tasks. ### Example Scripts: - **MessagingBetweenApps.jsx**: Shows how to send a message to a Creative Suite application and receive a response. - **MessageSendingToInDesign.jsx**: Sends a message to InDesign through BridgeTalk. - **SendArrayToPhotoshop.jsx**: Sends an array to Photoshop, which creates it in the target and passes it back. - **SendObjectToPhotoshop.jsx**: Sends a JavaScript object to Photoshop, which creates it in the target and passes it back. - **SendDOMObjectToPhotoshop.jsx**: Sends a DOM object to Photoshop, creating it in the target and passing values back. - **SaveAsDifferentFileType.jsx**: Locates an image file, uses messaging to load it into Photoshop, and saves it as a different file type. ``` -------------------------------- ### Example Function Signatures Source: https://extendscript.docsforadobe.dev/integrating-external-libraries/defining-entry-points-for-direct-access Illustrates how to represent function signatures for 'One' with an Integer and String argument, and 'Two' with no arguments. ```plaintext "One_ds" "Two" ``` -------------------------------- ### Define function signature array Source: https://extendscript.docsforadobe.dev/print_page Example format for returning function name and argument type signatures during library initialization. ```JSON ["functionName1_argtypes", "functionName2_argtypes", "functionName3"] ``` -------------------------------- ### Create and Populate a Two-Column ListBox Source: https://extendscript.docsforadobe.dev/user-interface-tools/types-of-controls This example demonstrates creating a ListBox with two columns, including headers, and populating it with items. The second column can contain both text and an image. ```javascript // create list box with two titled columns var list = dlg.add ("ListBox", [0, 0, 150, 75], "asd", {numberOfColumns: 2, showHeaders: true, columnTitles: ["First Name", "Last Name"]}); // add an item for the first row, with the label value for the first column var item1 = list.add ("item", "John"); // add the label value for the second column in that row. item1.subItems[0].text = "Doe"; // add an item for the second row, with the text for the first column label var item2 = list.add ("item", "Jane"); // add the label text and image for the second column in the second row item2.subItems[0].text = "Doe"; item2.subItems[0].image = File ("~/Desktop/Step1.png"); ... ``` -------------------------------- ### MessagingBetweenApps.jsx Example Source: https://extendscript.docsforadobe.dev/interapplication-communication/messaging-framework-api-reference Demonstrates sending a message to a Creative Suite application and receiving a response. This script is part of the Adobe ExtendScript SDK. ```javascript // MessagingBetweenApps.jsx // This script demonstrates interapplication messaging. ``` -------------------------------- ### Get All Target Applications Source: https://extendscript.docsforadobe.dev/print_page Retrieves a list of all messaging-enabled applications installed on the computer without version or locale filtering. ```javascript BridgeTalk.getTargets(); => [photoshop,illustrator] ``` -------------------------------- ### Implement a Simple Web Server Source: https://extendscript.docsforadobe.dev/external-communication/socket-object Listens for incoming connections on a specified port and responds with a dummy HTML page. ```javascript conn = new Socket; // listen on port 80 if (conn.listen (80)) { // wait forever for a connection var incoming; do incoming = conn.poll(); while (incoming == null); // discard the request conn.read(); // Reply with a HTTP header incoming.writeln ("HTTP/1.0 200 OK"); incoming.writeln ("Content-Type: text/html"); incoming.writeln(); // Transmit a dummy homepage incoming.writeln ("

Homepage

"); // done! incoming.close(); delete incoming; } ``` -------------------------------- ### Absolute Path Example Source: https://extendscript.docsforadobe.dev/file-system-access/using-file-and-folder-objects An absolute path in URI notation specifies the full path from the root directory to a file or folder, starting with one or two slashes. ```plaintext /dir1/dir2/mydir/myFile.jsx ``` -------------------------------- ### Get Target Applications with Version Source: https://extendscript.docsforadobe.dev/interapplication-communication/bridgetalk-class Retrieves a list of messaging-enabled applications, filtered by a specific major version. Use this to find all installed versions of an application that match a major version number. ```javascript BridgeTalk.getTargets( "9" ) => [photoshop-9.5] ``` ```javascript BridgeTalk.getTargets( "-9.9" ) => [photoshop-9.0, photoshop-9.5] ``` -------------------------------- ### Locate C/C++ SDK samples Source: https://extendscript.docsforadobe.dev/print_page Path to the directory containing sample code for integrating C/C++ shared libraries. ```text sdkInstall/sdksamples/cpp/ ``` -------------------------------- ### Get Target Applications with Version Filtering Source: https://extendscript.docsforadobe.dev/print_page Retrieve specific versions of messaging-enabled applications. Use a major version number to get the highest minor version, or a negative number to get all versions up to that point. ```javascript BridgeTalk.getTargets( "9" ) => [photoshop-9.5] ``` ```javascript BridgeTalk.getTargets( "-9.9" ) => [photoshop-9.0, photoshop-9.5] ``` -------------------------------- ### Library Initialization and Function Signatures Source: https://extendscript.docsforadobe.dev/print_page Explains how ExtendScript initializes a library using ESInitialize() and how to define function signatures for type casting and reflection. ```APIDOC ## Library initialization ExtendScript calls ESInitialize() to initialize the library. The function receives an argument vector containing the additional arguments passed in to the ExternalObject constructor. The function can return an array of function name-signature strings, which are used to support the ExtendScript reflection interface, and to cast function arguments to specific types. You do not need to define a signature for a function in order to make it callable in JavaScript. ### Function signatures If you choose to return a set of function name-signature strings, each string associates a function name with that function's parameter types, if any. For example: ``` ["functionName1_argtypes", "functionName2_argtypes", "functionName3"] ``` For each function, the string begins with the function name, followed by an underscore character and a list of argument data types, represented as a single character for each argument. If the function does not have arguments, you can omit the trailing underscore character (unless there is an underscore in the function name). The characters that indicate data types are: Characeter | Description ---|--- `a` | Any type. The argument is not converted. This is the default, if no type is supplied or if a type code is unrecognized. `b` | Boolean `d` | signed 32 bit integer `u` | unsigned 32 bit integer `f` | 64 bit floating point `s` | String For example, suppose your library defines these two entry points: ``` One (Integer a, String b); Two (); ``` The signature strings for these two functions would be `"One_ds"`, `"Two"`. Warning You cannot define function overloading by returning multiple different signatures for one function. Attempting to do so produces undefined results. ``` -------------------------------- ### Chat Server and Client Sample Source: https://extendscript.docsforadobe.dev/print_page Sample code demonstrating a simple chat server and a corresponding client using the Socket object. ```APIDOC ## Chat Server and Client Sample This section provides sample code for a basic chat server and client. ### Chat Server (`chatServer` function) A chat server that listens on port 1234. It accepts connections, sends a welcome message, and facilitates a text-based conversation until either party types 'bye'. ### Chat Client (`chatClient` function) A chat client that connects to a specified server (e.g., `remote-pc.corp.adobe.com:1234`) and engages in a text-based conversation. ### Chat Function (`chat` function) A helper function used by both the server and client to manage the conversation loop, reading messages and sending responses. ``` -------------------------------- ### Window Methods: show() and update() Source: https://extendscript.docsforadobe.dev/print_page Details on how to show and update UI elements, including modal dialog behavior and status updates for long operations. ```APIDOC ## Window Methods: show() and update() ### show() `windowOrContainerObj.show()` Shows this window, container, or control. If an onShow callback is defined for a window, calls that function before showing the window. When a window or container is hidden, its children are also hidden, but when it is shown again, the children retain their own visibility states. For a modal dialog, opens the dialog and does not return until the dialog is dismissed. If it is dismissed via the close() method, this method returns any result value passed to that method. Otherwise, returns 0. #### Returns Nothing ### update() `windowOrContainerObj.update()` Allows a script to run a long operation (such as copying a large file) and update UI elements to show the status of the operation. Normally, drawing updates to UI elements occur during idle periods, when the application is not doing anything and the OS event queue is being processed, but during a long scripted operation, the normal event loop is not running. Use this method to perform the necessary synchronous drawing updates, and also process certain mouse and keyboard events in order to allow a user to cancel the current operation (by clicking a Cancel button, for instance). During the update() operation, the application is put into a modal state, so that it does not handle any events that would activate a different window, or give focus to a control outside the window being updated. The modal state allows drawing events for controls in other windows to occur (as is the case during a modal show() operation), so that the script does not prevent the update of other parts of the application's UI while in the operation loop. It is an error to call the update() method for a window that is not currently visible. #### Returns Nothing ``` -------------------------------- ### BridgeTalk.bringToFront Source: https://extendscript.docsforadobe.dev/print_page Brings all windows of the specified application to the front of the screen. ```APIDOC ## BridgeTalk.bringToFront() ### Description Brings all windows of the specified application to the front of the screen. ### Parameters #### Path Parameters - **app** (Application specifiers) - Required - A specifier for the target application ### Response - **Returns** (Nothing) ``` -------------------------------- ### Get Application Display Name Source: https://extendscript.docsforadobe.dev/interapplication-communication/bridgetalk-class Retrieves the display name of a specific Adobe application version. Use this to get a user-friendly name for an application. ```javascript BridgeTalk.getDisplayName("photoshop-10.0"); => Adobe Photoshop CS4 ``` -------------------------------- ### Check for installed application version in ExtendScript Source: https://extendscript.docsforadobe.dev/introduction/scripting-for-specific-applications Use BridgeTalk.getSpecifier() to check if a specific application and version are installed. This is crucial for scripts that depend on or communicate with other Adobe applications. ```javascript if ( BridgeTalk.appName == "bridge-2.0" ) { // Check to see that Photoshop is installed. if ( BridgeTalk.getSpecifier( "photoshop", 10 ) ){ // Add the Photoshop automate menu to the Adobe Bridge UI. } } ``` -------------------------------- ### XMPMeta Object Constructors Source: https://extendscript.docsforadobe.dev/scripting-xmp/xmpscript-object-reference Demonstrates how to create new XMPMeta objects, either empty or initialized with existing XMP data. ```APIDOC ## XMPMeta object constructors To create an `XMPMeta` object, use the `new` operator. The constructor accepts an RDF/XML serialized metadata packet as a string, or as an array of numbers that contain only byte values. It returns the new object. If no argument is supplied, the new object is empty; you can use the object's functions to add namespaces and properties. The first call to any of these constructors initializes the library by registering the standard namespaces and aliases: ```javascript new XMPMeta ( ); // creates an empty object new XMPMeta ( packet ); new XMPMeta ( buffer ); ``` ##### Parameters Parameter | Type | Description ---|---|--- `packet` | String | An XML file or an XMP packet. `buffer` | Array of Numbers | The UTF-8 or UTF-16 encoded bytes of an XML file or an XMP packet. This array is the result of XMPMeta.serializeToArray. ``` -------------------------------- ### get() Source: https://extendscript.docsforadobe.dev/print_page Called when JavaScript code accesses a property of this class. ```APIDOC ## get() ### Description Called when JavaScript code accesses a property of this class: ```javascript alert(xx.myproperty); ``` ### Parameters #### Path Parameters - **hObject** (SoHObject) - Required - The Support structures reference for an instance of this class. - **name** (SoCClientName*) - Required - The name of the property, a pointer to an SoCClientName. - **pValue** (TaggedData*) - Required - A buffer in which to return the property value, a TaggedData. ### Returns Returns an error code, kESErrOK on success. ``` -------------------------------- ### GET /ExternalObject/search Source: https://extendscript.docsforadobe.dev/print_page Checks if a library can be found without loading it. ```APIDOC ## GET /ExternalObject/search ### Description Reports whether a compiled C/C++ library can be found. If ExternalObject.log is true, search paths are reported to the console. ### Method GET ### Endpoint ExternalObject.search(spec) ### Parameters #### Query Parameters - **spec** (String) - Required - The file specification for the compiled library. ### Response #### Success Response (200) - **result** (Boolean) - true if the library is found, false otherwise. ``` -------------------------------- ### BridgeTalk.launch() Source: https://extendscript.docsforadobe.dev/interapplication-communication/bridgetalk-class Launches a specified application on the local computer. Applications are automatically launched when a message is sent to them if they are not already running. ```APIDOC ## BridgeTalk.launch() ### Description Launches the given application on the local computer. It is not necessary to launch an application explicitly in order to send it a message; sending a message to an application that is not running automatically launches it. ### Method BridgeTalk.launch(specifier[, where]) ### Parameters #### Path Parameters - **specifier** (Application specifiers) - Required - A specifier for the target application. - **where** (Unknown) - Optional - If the value "background" is specified, the application's main window is not brought to the front of the screen. ### Returns Boolean. `true` if the application has already been launched, `false` if it was launched by this call. ``` -------------------------------- ### BridgeTalk.getTargets() Source: https://extendscript.docsforadobe.dev/interapplication-communication/bridgetalk-class Retrieves a list of messaging-enabled applications installed on this computer. ```APIDOC ## BridgeTalk.getTargets() ### Description Retrieves a list of messaging-enabled applications installed on this computer. ### Method BridgeTalk.getTargets([version],[locale]) ### Parameters #### Path Parameters - **version** (Number) - Optional - The specific version number to search for, or `null` to return the most appropriate version (matching, most recent, or running), with version information. Specify only a major version number to return the highest minor-version variation. Specify a negative value to return all versions up to the absolute value of the version number. - **locale** (String) - Optional - The specific locale to search for, or null to return applications for all locales, with locale information. If not supplied when version is supplied, returns specifiers with version information only. ### Request Example ```javascript BridgeTalk.getTargets( "9" ) // => ["photoshop-9.5"] BridgeTalk.getTargets( "-9.9" ) // => ["photoshop-9.0", "photoshop-9.5"] ``` ### Response #### Success Response (200) - **specifiers** (Array) - Returns an array of Application specifiers. - If version is supplied, specifiers include the base name plus the version information. - If locale is supplied, specifiers include the full name, with both version and locale information. - If neither version nor locale is supplied, returns base specifiers with neither version nor locale information, but tries to find the most appropriate version and locale. ``` -------------------------------- ### File.read() Source: https://extendscript.docsforadobe.dev/file-system-access/file-object Reads the contents of the file starting at the current position. ```APIDOC ## File.read() ### Description Reads the contents of the file starting at the current position. ### Parameters #### Path Parameters - **chars** (Number) - Optional - An integer specifying the number of characters to read. ### Response #### Success Response (200) - **Return** (String) - A string that contains up to the specified number of characters. ``` -------------------------------- ### Slider Control Source: https://extendscript.docsforadobe.dev/print_page Documentation for the slider control, including its parameters and creation example. ```APIDOC ## Slider Control ### Class Name `Slider` ### Description A slider with a moveable position indicator. All `slider` controls have a horizontal orientation. Calls the onChange callback after the position of the indicator is changed or if its notify() method is called. Calls the `onChanging` callback repeatedly while the user is moving the indicator. The `value` property contains the current position of the indicator within the range of `minvalue` and `maxvalue`. ### Parameters - **bounds** (Bounds object) - Optional. The control's position and size. - **value** (Number) - Optional. The initial position of the scroll indicator. Default is 0. - **minvalue** (Number) - Optional. The minimum value that the `value` property can be set to. Default is 0. Together with `maxvalue`, defines the range. - **maxvalue** (Number) - Optional. The maximum value that the `value` property can be set to. Default is 100. Together with `minvalue`, defines the range. - **creation_properties** (Object) - Optional. An object that contains any of the properties below. ### Creation Properties - **name** (String) - Required - A unique name for the control. ### Example To add to a window `w`: ```javascript w.add("slider"[, bounds, value, minvalue, maxvalue, {creation_properties}]); ``` ``` -------------------------------- ### File.tell() Source: https://extendscript.docsforadobe.dev/file-system-access/file-object Retrieves the current position index as a byte offset from the start of the file. ```APIDOC ## File.tell() ### Description Retrieves the current position index as a byte offset from the start of the file. ### Response #### Success Response (200) - **result** (Number) - The current byte offset. ``` -------------------------------- ### Function Signature String Format Source: https://extendscript.docsforadobe.dev/integrating-external-libraries/defining-entry-points-for-direct-access This example shows the format for function signature strings returned by ESInitialize. Each string associates a function name with its argument data types, represented by single characters. ```plaintext ["functionName1_argtypes", "functionName2_argtypes", "functionName3"] ``` -------------------------------- ### Scrollbar Control Source: https://extendscript.docsforadobe.dev/print_page Documentation for the scrollbar control, detailing its properties, parameters, and creation example. ```APIDOC ## Scrollbar Control ### Class Name `Scrollbar` ### Description A scrollbar with a draggable scroll indicator and stepper buttons to move the indicator. The `scrollbar` control has a horizontal orientation if the `width` is greater than the `height` at creation time, or vertical if its `height` is greater than its `width`. Calls the onChange callback after the position of the indicator is changed or if its notify() method is called. Calls the onChanging callback repeatedly while the user is moving the indicator. ### Properties - **value** (Number) - Contains the current position of the scrollbar's indicator within the scrolling area, within the range of `minvalue` and `maxvalue`. - **stepdelta** (Number) - Determines the scrolling unit for the up or down arrow. Default is `1`. - **jumpdelta** (Number) - Determines the scrolling unit for a jump (as when the bar is clicked outside the indicator or arrows); default is 20% of the range between `minvalue` and `maxvalue`. ### Parameters - **bounds** (Bounds object) - Optional. The control's position and size. - **value** (Number) - Optional. The initial position of the scroll indicator. Default is 0. - **minvalue** (Number) - Optional. The minimum value that the `value` property can be set to. Default is 0. Together with `maxvalue`, defines the scrolling range. - **maxvalue** (Number) - Optional. The maximum value that the `value` property can be set to. Default is 100. Together with `minvalue`, defines the scrolling range. - **creation_properties** (Object) - Optional. An object that contains any of the properties below. ### Creation Properties - **name** (String) - Required - A unique name for the control. ### Example To add to a window `w`: ```javascript w.add("scrollbar"[, bounds, value, minvalue, maxvalue, {creation_properties}]); ``` ``` -------------------------------- ### POST /ExternalObject/constructor Source: https://extendscript.docsforadobe.dev/print_page Initializes a new ExternalObject instance by loading a specified shared library. ```APIDOC ## POST /ExternalObject/constructor ### Description Creates a new ExternalObject instance and loads the specified C/C++ library. ### Method POST ### Endpoint new ExternalObject("lib:" + filespec, arg1, ...argn) ### Parameters #### Path Parameters - **filespec** (String) - Required - The base name of the shared library, prefixed with "lib:". #### Request Body - **arg1...argn** (Any) - Optional - Arguments to pass to the library's initialization routine. ### Request Example { "filespec": "myLibrary", "args": [] } ### Response #### Success Response (200) - **ExternalObject** (Object) - The loaded library instance. ``` -------------------------------- ### closePath() Source: https://extendscript.docsforadobe.dev/print_page Closes the current path by drawing a line from the current position to the start point. ```APIDOC ## closePath() ### Description Defines a line from the current position to the start point of the current path (the value of currentPath), which closes the path. ### Returns Nothing ``` -------------------------------- ### Read and Write User Data Files Source: https://extendscript.docsforadobe.dev/file-system-access/file-object Demonstrates reading from and writing to the user's application data folder using the Folder.userData shortcut. ```javascript /** * Reads data from a given file in userdata folder * * @param {string} filename Filename, with extension * @return {string} File contents, if file exists */ function readUserDataFromFile(filename) { var userDataFolder = Folder.userData; var filepath = userDataFolder.fullName + "/" + filename; var file = new File(filepath); // Default encoding file.encoding = "UTF-8"; if (!file.exists) { throw "Could not find file '" + String(file.fsName); } file.open(); var contents = file.read(); file.close(); return contents; } /** * Writes data to a given file in userdata folder * * @param {string} filename Filename, with extension * @param {string} data Data to write */ function writeUserDataToFile(filename, data) { var userDataFolder = Folder.userData; var filepath = userDataFolder.fullName + "/" + filename; var file = new File(filepath); // Default encoding file.encoding = "UTF-8"; // Write file contents file.open("w"); var success = file.write(data); file.close(); if (!success) { throw "Could not write to file '" + String(file.fsName); } } try { var filename = "myFile.txt"; var contents = "Hello world!"; writeUserDataToFile(filename, contents); var readData = readUserDataFromFile(filename); // "Hello world!" alert("File Contents: '" + String(readData) + "'"); } catch (e) { alert(e); } ``` -------------------------------- ### Create a Simple Web Server Source: https://extendscript.docsforadobe.dev/print_page This server-side code listens on a specific port (e.g., 80) for incoming connections. It accepts a connection, discards the request, sends a basic HTTP response header, and transmits a dummy HTML page. The connection is closed upon completion. ```javascript conn = new Socket; // listen on port 80 if (conn.listen (80)) { // wait forever for a connection var incoming; do incoming = conn.poll(); while (incoming == null); // discard the request conn.read(); // Reply with a HTTP header incoming.writeln ("HTTP/1.0 200 OK"); incoming.writeln ("Content-Type: text/html"); incoming.writeln(); // Transmit a dummy homepage incoming.writeln ("

Homepage

"); // done! incoming.close(); delete incoming; } ``` -------------------------------- ### XML Traversal Methods Source: https://extendscript.docsforadobe.dev/print_page Examples of using children(), elements(), and descendants() to inspect XML structure. ```javascript x.children() x.children().length() ``` ```javascript x.elements() x.elements().length() ``` ```javascript x.descendants() x.descendants().length() ``` -------------------------------- ### Namespace Specifier Usage Source: https://extendscript.docsforadobe.dev/print_page Examples of calling cross-DOM or exported functions using namespace specifiers. ```javascript photoshop.quit() ``` ```javascript illustrator.quit() ``` ```javascript illustrator15.place(myFiles) ``` -------------------------------- ### show() Source: https://extendscript.docsforadobe.dev/user-interface-tools/control-objects Shows the container or control. ```APIDOC ## show() ### Description Shows this container or control. Children retain their own visibility states when the parent is shown again. ### Returns - Nothing ``` -------------------------------- ### Application Specifier Examples Source: https://extendscript.docsforadobe.dev/print_page Commonly used application specifier strings for identifying Adobe applications. ```text photoshop ``` ```text bridge-3.0 ``` ```text indesign_1-6.0 ``` ```text illustrator-14.0 ``` ```text illustrator-14.0-de_de ``` -------------------------------- ### Create and Manipulate Metadata Source: https://extendscript.docsforadobe.dev/scripting-xmp/accessing-the-xmp-scripting-api Demonstrates creating an empty XMPMeta object, setting properties, serializing to XML, and retrieving property values. ```javascript var xmp = new XMPMeta(); xmp.setProperty( XMPConst.NS_XMP, "CreatorTool", "My Script" ); var xmpStr = xmp.serialize(); // Serialize the XMP packet to XML // Retrieve property var prop = xmp.getProperty(XMPConst.NS_XMP, "CreatorTool"); $.writeln( "namespace: " + prop.namespace + "\n" + "property path + name: " + prop.path + "\n" + "value: " + prop ); // same as prop.value ``` -------------------------------- ### $.flags Property Source: https://extendscript.docsforadobe.dev/print_page Gets or sets low-level debug output flags using bitwise values. ```APIDOC ## $.flags ### Description Gets or sets low-level debug output flags. A logical AND of bit flag values (e.g., 0x0002 for line numbers, 0x0040 for garbage collection). ### Type Number ``` -------------------------------- ### BridgeTalk.loadAppScript() Source: https://extendscript.docsforadobe.dev/interapplication-communication/bridgetalk-class Loads the startup script for an application from the common StartupScripts folders, useful for implementing late loading of scripts. ```APIDOC ## BridgeTalk.loadAppScript() ### Description Loads the startup script for an application from the common StartupScripts folders. Use to implement late loading of startup scripts. ### Method BridgeTalk.loadAppScript(specifier) ### Parameters #### Path Parameters - **specifier** (Application specifiers) - Required - A specifier for the target application. ### Returns Boolean. `true` if the script was successfully loaded. ``` -------------------------------- ### BridgeTalk.getTargets() Source: https://extendscript.docsforadobe.dev/print_page Retrieves a list of messaging-enabled applications installed on the computer, with options to filter by version and locale. ```APIDOC ## BridgeTalk.getTargets() ### Description Retrieves a list of messaging-enabled applications installed on this computer. ### Method GET (conceptual) ### Endpoint BridgeTalk.getTargets([version],[locale]) ### Parameters #### Query Parameters - **version** (Number) - Optional. The specific version number to search for, or `null` to return the most appropriate version (matching, most recent, or running), with version information. Specify only a major version number to return the highest minor-version variation. Specify a negative value to return all versions up to the absolute value of the version number. - **locale** (String) - Optional. The specific locale to search for, or null to return applications for all locales, with locale information. If not supplied when version is supplied, returns specifiers with version information only. ### Response #### Success Response (200) Returns an array of Application specifiers. If version is supplied, specifiers include the base name plus the version information. If locale is supplied, specifiers include the full name, with both version and locale information. If neither version nor locale is supplied, returns base specifiers with neither version nor locale information, but tries to find the most appropriate version and locale. ### Request Example ```javascript BridgeTalk.getTargets(); // => [photoshop,illustrator] BridgeTalk.getTargets( "9" ); // => [photoshop-9.5] BridgeTalk.getTargets( "-9.9" ); // => [photoshop-9.0, photoshop-9.5] BridgeTalk.getTargets( null ); // => [photoshop-11.0, illustrator-14.0] BridgeTalk.getTargets( null, "en_US" ); // => [photoshop-10.0-en_US, photoshop-11.0-en_US] BridgeTalk.getTargets( null, null ); // => [photoshop-10.0-en_US, photoshop-11.0-en_us, illustrator-14.0-de_de] ``` ``` -------------------------------- ### File.tell() Method Source: https://extendscript.docsforadobe.dev/file-system-access/file-object Returns the current file pointer position as a byte offset from the start of the file. ```javascript fileObj.tell() ``` -------------------------------- ### Construct QName Objects Source: https://extendscript.docsforadobe.dev/integrating-xml/xml-object-reference Initializes a QName object, which encapsulates a local name and a namespace URI. ```javascript new QName () new QName (name) new QName (ns) new QName (uri, name) ``` -------------------------------- ### Modify XML Elements and Attributes Source: https://extendscript.docsforadobe.dev/integrating-xml/the-xml-object Examples of updating XML content and attributes by assigning values to properties. ```javascript bookstoreXML.book[2].author = "Charles 'Lewis Carroll' Dodgeson"; ``` ```javascript Alice's Adventures in Wonderland Charles 'Lewis Carroll' Dodgeson 1865 29.99 ``` ```javascript bookstoreXML.book[2].author[0] = "Charles Dodgeson, aka Lewis Carroll"; ``` ```javascript bookstoreXML.book[1].year = 1901; ``` ```javascript > bookstoreXML.book[1].rating = "**\***"; ``` ```javascript The Wonderful Wizard of Oz L. Frank Baum 1900 39.95 ***** ``` ```javascript bookstoreXML.book[1].@category = "LITERATURE, FANTASY" ``` ```javascript The Wonderful Wizard of Oz ... ``` -------------------------------- ### Compare localization methods Source: https://extendscript.docsforadobe.dev/print_page Demonstrates the difference between using automatic localization and the explicit localize function. ```javascript // Only works if the $.localize = true var b1 = win.add ( "button", undefined, btnText ); // Always works, regardless of $.localize value var b1 = win.add ( "button", undefined, localize( btnText ) ); ``` -------------------------------- ### Call remote application function Source: https://extendscript.docsforadobe.dev/interapplication-communication/communications-overview Example of invoking a specific function in another application using its namespace. ```javascript photoshop.photomerge(files) ``` -------------------------------- ### Adding UI Controls Source: https://extendscript.docsforadobe.dev/print_page Demonstrates the general syntax for adding UI controls to a window or container using the `add` method. ```APIDOC ## General Control Addition ### Description Adds a new UI control or container to a parent object (Window, Panel, or Group). ### Method `add(type, bounds, text, creation_props)` ### Parameters #### Path Parameters - **type** (String) - Required - The control type. See Control types and creation parameters. - **bounds** (Bounds object) - Optional - A bounds specification that describes the size and position of the new control or container, relative to its parent. - **text** (String) - Optional - Initial text to be displayed in the control. - **creation_props** (Object) - Optional - Properties specific to each object type for creation. ### Returns Returns the new object, or `null` if unable to create the object. ``` -------------------------------- ### Get property data type Source: https://extendscript.docsforadobe.dev/print_page Retrieves the data type of a specific property using the find method. ```javascript Math.reflect.find ("PI").type; // => number ``` -------------------------------- ### Query Installed Applications with BridgeTalk.getTargets Source: https://extendscript.docsforadobe.dev/interapplication-communication/bridgetalk-class Retrieves a list of available applications based on version and locale filters. ```javascript BridgeTalk.getTargets(); => [photoshop,illustrator] BridgeTalk.getTargets( "10.0" ); => [photoshop-10.0] BridgeTalk.getTargets( null ); => [photoshop-11.0, illustrator-14.0] BridgeTalk.getTargets( null, "en_US" ); => [photoshop-10.0-en_US, photoshop-11.0-en_US] BridgeTalk.getTargets( null, null ); => [photoshop-10.0-en_US, photoshop-11.0-en_us, illustrator-14.0-de_de] ``` -------------------------------- ### ScriptUI.compatability Source: https://extendscript.docsforadobe.dev/print_page Reference for the `ScriptUI.compatability` object. ```APIDOC ## ScriptUI.compatability ### Description Provides information related to ScriptUI compatibility. ``` -------------------------------- ### Delete XML Elements and Attributes Source: https://extendscript.docsforadobe.dev/integrating-xml/the-xml-object Examples of using the delete operator to remove specific XML elements or attributes. ```javascript delete bookstoreXML.book[2].author; ``` ```javascript delete bookstoreXML.book[2].author[1]; ``` ```javascript delete bookstoreXML.book[2].@category; ``` -------------------------------- ### Window Object Constructor Source: https://extendscript.docsforadobe.dev/print_page Creates and returns a new Window object. ```APIDOC # Window Object ## Window Object constructor The constructor creates and returns a new Window object, or null if window creation failed. ### Method `new Window (type [, title, bounds, {creation_properties}]);` ### Parameters #### Path Parameters - **type** (String) - The window type. One of: "dialog" - Creates a modal dialog. "palette" - Creates a modeless dialog, also called a floating palette. (Not supported by Photoshop CC.) "window" - Creates a simple window that can be used as a main window for an application. (Not supported by Photoshop CC.). This argument can be a ScriptUI resource specification; in this case, all other arguments are ignored. See Resource specifications. - **title** (String) - Optional. The window title. A localizable string. - **bounds** (Bounds object) - Optional. The window's position and size. - **creation_properties** (Object) - Optional. An object that contains any of the properties below. ### Response #### Success Response (200) - **return value** (Window object or null) - A new Window object or null if creation failed. ### Request Example ```javascript var myDialog = new Window("dialog", "My Custom Dialog", undefined, {resizeable: true}); ``` ``` -------------------------------- ### File.read() Source: https://extendscript.docsforadobe.dev/print_page Reads the contents of a file starting from the current position and returns a string containing a specified number of characters. ```APIDOC ## File.read() ### Description Reads the contents of the file starting at the current position. Returns a string that contains up to the specified number of characters. ### Method `fileObj.read([chars])` ### Parameters #### Path Parameters - **chars** (Number) - Optional - The maximum number of characters to read. ``` -------------------------------- ### Create a Folder Object Source: https://extendscript.docsforadobe.dev/file-system-access/folder-object Use the Folder constructor or the new operator to initialize a Folder object. The constructor accepts an optional path string. ```javascript Folder( [path] ); // Can return a File object new Folder( [path] ); // Always returns a Folder object ``` -------------------------------- ### View XML Object Content Source: https://extendscript.docsforadobe.dev/integrating-xml/the-xml-object Examples of evaluating XML objects in the ExtendScript Toolkit console to view their structure or values. ```javascript > bookstoreXML.book[1]; The Wonderful Wizard of Oz L. Frank Baum 1900 39.95 ``` ```javascript > bookstoreXML.book[1].@category; CHILDREN ``` ```javascript > bookstoreXML.book.@category COOKINGCHILDRENCHILDRENMUSIC ``` -------------------------------- ### Folder Object Constructors Source: https://extendscript.docsforadobe.dev/print_page Explains how to create Folder objects using the Folder function or the new operator, detailing the path parameter and its behavior. ```APIDOC ## Folder Object Constructors ```javascript Folder( [path] ); // Can return a File object new Folder( [path] ); // Always returns a Folder object ``` ### Description To create a Folder object, use the Folder function or the new operator. The constructor accepts full or partial path names, and returns the new object. ### Parameters #### Path Parameters - **path** (String) - Optional - The absolute or relative path to the Folder associated with this object, specified in platform-specific or URI format. The value stored in the object is the absolute path. The path need not refer to an existing Folder. If not supplied, a temporary name is generated. If the path refers to an existing file: The Folder function returns a File object instead of a File object. The new operator returns a Folder object for a nonexisting folder with the same name. **Warning**: In After Effects on MacOS, if `path.length` is more than 1002, After Effects crashes. This has been reported on MacOS 10.11.6 and After Effects 13.8 and 14.0. ``` -------------------------------- ### Get Resource Text Source: https://extendscript.docsforadobe.dev/print_page ScriptUI.getResourceText() retrieves a resource string from the host application. If no match is found, the original text is returned. ```javascript ScriptUI.getResourceText(text) ``` -------------------------------- ### Initialize ExternalObject Source: https://extendscript.docsforadobe.dev/integrating-external-libraries/externalobject-object Instantiate an ExternalObject by specifying the library name prefixed with 'lib:'. ```javascript var mylib = new ExternalObject( "lib:myLibrary" ); ``` -------------------------------- ### Show a Dialog Window Source: https://extendscript.docsforadobe.dev/user-interface-tools/scriptui-programming-model Makes a previously created window visible and responsive to user interaction. Call this after defining the window's content and properties. ```javascript dlg.show(); ```