AK-21/Graphite-Industrial-Intelligence
0
1/*! *****************************************************************************2Copyright (c) Microsoft Corporation. All rights reserved.3Licensed under the Apache License, Version 2.0 (the "License"); you may not use4this file except in compliance with the License. You may obtain a copy of the5License at http://www.apache.org/licenses/LICENSE-2.06 7THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY8KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED9WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,10MERCHANTABILITY OR NON-INFRINGEMENT.11 12See the Apache Version 2.0 License for specific language governing permissions13and limitations under the License.14***************************************************************************** */15 16 17/////////////////////////////18/// Windows Script Host APIS19/////////////////////////////20 21interface ActiveXObject {22 new (s: string): any;23}24declare var ActiveXObject: ActiveXObject;25 26interface ITextWriter {27 Write(s: string): void;28 WriteLine(s: string): void;29 Close(): void;30}31 32interface TextStreamBase {33 /**34 * The column number of the current character position in an input stream.35 */36 Column: number;37 38 /**39 * The current line number in an input stream.40 */41 Line: number;42 43 /**44 * Closes a text stream.45 * It is not necessary to close standard streams; they close automatically when the process ends. If46 * you close a standard stream, be aware that any other pointers to that standard stream become invalid.47 */48 Close(): void;49}50 51interface TextStreamWriter extends TextStreamBase {52 /**53 * Sends a string to an output stream.54 */55 Write(s: string): void;56 57 /**58 * Sends a specified number of blank lines (newline characters) to an output stream.59 */60 WriteBlankLines(intLines: number): void;61 62 /**63 * Sends a string followed by a newline character to an output stream.64 */65 WriteLine(s: string): void;66}67 68interface TextStreamReader extends TextStreamBase {69 /**70 * Returns a specified number of characters from an input stream, starting at the current pointer position.71 * Does not return until the ENTER key is pressed.72 * Can only be used on a stream in reading mode; causes an error in writing or appending mode.73 */74 Read(characters: number): string;75 76 /**77 * Returns all characters from an input stream.78 * Can only be used on a stream in reading mode; causes an error in writing or appending mode.79 */80 ReadAll(): string;81 82 /**83 * Returns an entire line from an input stream.84 * Although this method extracts the newline character, it does not add it to the returned string.85 * Can only be used on a stream in reading mode; causes an error in writing or appending mode.86 */87 ReadLine(): string;88 89 /**90 * Skips a specified number of characters when reading from an input text stream.91 * Can only be used on a stream in reading mode; causes an error in writing or appending mode.92 * @param characters Positive number of characters to skip forward. (Backward skipping is not supported.)93 */94 Skip(characters: number): void;95 96 /**97 * Skips the next line when reading from an input text stream.98 * Can only be used on a stream in reading mode, not writing or appending mode.99 */100 SkipLine(): void;101 102 /**103 * Indicates whether the stream pointer position is at the end of a line.104 */105 AtEndOfLine: boolean;106 107 /**108 * Indicates whether the stream pointer position is at the end of a stream.109 */110 AtEndOfStream: boolean;111}112 113declare var WScript: {114 /**115 * Outputs text to either a message box (under WScript.exe) or the command console window followed by116 * a newline (under CScript.exe).117 */118 Echo(s: any): void;119 120 /**121 * Exposes the write-only error output stream for the current script.122 * Can be accessed only while using CScript.exe.123 */124 StdErr: TextStreamWriter;125 126 /**127 * Exposes the write-only output stream for the current script.128 * Can be accessed only while using CScript.exe.129 */130 StdOut: TextStreamWriter;131 Arguments: { length: number; Item(n: number): string; };132 133 /**134 * The full path of the currently running script.135 */136 ScriptFullName: string;137 138 /**139 * Forces the script to stop immediately, with an optional exit code.140 */141 Quit(exitCode?: number): number;142 143 /**144 * The Windows Script Host build version number.145 */146 BuildVersion: number;147 148 /**149 * Fully qualified path of the host executable.150 */151 FullName: string;152 153 /**154 * Gets/sets the script mode - interactive(true) or batch(false).155 */156 Interactive: boolean;157 158 /**159 * The name of the host executable (WScript.exe or CScript.exe).160 */161 Name: string;162 163 /**164 * Path of the directory containing the host executable.165 */166 Path: string;167 168 /**169 * The filename of the currently running script.170 */171 ScriptName: string;172 173 /**174 * Exposes the read-only input stream for the current script.175 * Can be accessed only while using CScript.exe.176 */177 StdIn: TextStreamReader;178 179 /**180 * Windows Script Host version181 */182 Version: string;183 184 /**185 * Connects a COM object's event sources to functions named with a given prefix, in the form prefix_event.186 */187 ConnectObject(objEventSource: any, strPrefix: string): void;188 189 /**190 * Creates a COM object.191 * @param strProgiID192 * @param strPrefix Function names in the form prefix_event will be bound to this object's COM events.193 */194 CreateObject(strProgID: string, strPrefix?: string): any;195 196 /**197 * Disconnects a COM object from its event sources.198 */199 DisconnectObject(obj: any): void;200 201 /**202 * Retrieves an existing object with the specified ProgID from memory, or creates a new one from a file.203 * @param strPathname Fully qualified path to the file containing the object persisted to disk.204 * For objects in memory, pass a zero-length string.205 * @param strProgID206 * @param strPrefix Function names in the form prefix_event will be bound to this object's COM events.207 */208 GetObject(strPathname: string, strProgID?: string, strPrefix?: string): any;209 210 /**211 * Suspends script execution for a specified length of time, then continues execution.212 * @param intTime Interval (in milliseconds) to suspend script execution.213 */214 Sleep(intTime: number): void;215};216 217/**218 * WSH is an alias for WScript under Windows Script Host219 */220declare var WSH: typeof WScript;221 222/**223 * Represents an Automation SAFEARRAY224 */225declare class SafeArray<T = any> {226 private constructor();227 private SafeArray_typekey: SafeArray<T>;228}229 230/**231 * Allows enumerating over a COM collection, which may not have indexed item access.232 */233interface Enumerator<T = any> {234 /**235 * Returns true if the current item is the last one in the collection, or the collection is empty,236 * or the current item is undefined.237 */238 atEnd(): boolean;239 240 /**241 * Returns the current item in the collection242 */243 item(): T;244 245 /**246 * Resets the current item in the collection to the first item. If there are no items in the collection,247 * the current item is set to undefined.248 */249 moveFirst(): void;250 251 /**252 * Moves the current item to the next item in the collection. If the enumerator is at the end of253 * the collection or the collection is empty, the current item is set to undefined.254 */255 moveNext(): void;256}257 258interface EnumeratorConstructor {259 new <T = any>(safearray: SafeArray<T>): Enumerator<T>;260 new <T = any>(collection: { Item(index: any): T; }): Enumerator<T>;261 new <T = any>(collection: any): Enumerator<T>;262}263 264declare var Enumerator: EnumeratorConstructor;265 266/**267 * Enables reading from a COM safe array, which might have an alternate lower bound, or multiple dimensions.268 */269interface VBArray<T = any> {270 /**271 * Returns the number of dimensions (1-based).272 */273 dimensions(): number;274 275 /**276 * Takes an index for each dimension in the array, and returns the item at the corresponding location.277 */278 getItem(dimension1Index: number, ...dimensionNIndexes: number[]): T;279 280 /**281 * Returns the smallest available index for a given dimension.282 * @param dimension 1-based dimension (defaults to 1)283 */284 lbound(dimension?: number): number;285 286 /**287 * Returns the largest available index for a given dimension.288 * @param dimension 1-based dimension (defaults to 1)289 */290 ubound(dimension?: number): number;291 292 /**293 * Returns a Javascript array with all the elements in the VBArray. If there are multiple dimensions,294 * each successive dimension is appended to the end of the array.295 * Example: [[1,2,3],[4,5,6]] becomes [1,2,3,4,5,6]296 */297 toArray(): T[];298}299 300interface VBArrayConstructor {301 new <T = any>(safeArray: SafeArray<T>): VBArray<T>;302}303 304declare var VBArray: VBArrayConstructor;305 306/**307 * Automation date (VT_DATE)308 */309declare class VarDate {310 private constructor();311 private VarDate_typekey: VarDate;312}313 314interface DateConstructor {315 new (vd: VarDate): Date;316}317 318interface Date {319 getVarDate: () => VarDate;320}321 