The global object defines several functions that are directly accessible to the script.
interface IGlobal {
// Properties
readonly ${apiVersion}: number;
readonly ${activeDocument}: ${IDocument};
readonly ${activeView}: ${IDocumentView};
readonly ${wholeFile}: ${ISelection};
readonly ${documents}: ${IDocument}[];
readonly ${activeProcessWindow}: ${IProcessWindow};
// Methods
// Control Flow and Tracing Methods
${log}(message: any): void;
${alert}(message: any, params?: { title?: string; buttons?: ${AlertButtons}; icon?: ${AlertIcon} }): ${AlertResult};
${input}(message: string): string;
${async}(handler: () => void, ms: number, repetitive = false): number;
${cancelAsync}(handlerId: number): void;
${delay}(ms: number): Promise<void>;
${loadTextFile}(path: string): string;
${stopScript}(): void;
// Pattern Object Creation Methods
${createPattern}(): ${IPattern};
${createPattern#createPattern1}(text: string, encoding?: ${Encodings}): void;
${createPattern#createPattern2}(data: number[], dataType = ${ValueType}.Byte, bigEndian = false): ${IPattern};
${createPattern#createPattern3}(data: Uint8Array | Uint16Array | Uint32Array): ${IPattern};
// New Document Creation Methods
${newDocument}(format?: string): ${IDocument};
// Document Opening Methods
${openFile}(path: string, mode = ${OpeningMode}.Normal, readOnly = false, format?: string): ${IDocument};
${openVolume}(path: string, friendlyName?: string, mode = ${OpenVolumeMode}.ReadOnly): ${IDocument};
${openDisk}(path: string, friendlyName?: string, readOnly = true): ${IDocument};
${openHexAsync}(path: string, format: ${HexFormat}, flags = ${InsertHexFlags}.None): ${IDocument};
// Window Management Methods
${activate}(value: string | ${IWindow}): void;
${closeAll}(closeMode = ${CloseMode}.Prompt): boolean;
// General Application Control Methods
${displaySettings}(page?: string, hideOtherPages = false): void;
${exportSettings}(path?: string): boolean;
${importSettings}(path?: string): boolean;
${restart}(message?: string): void;
${exportConfiguration}(path?: string): boolean;
${importConfiguration}(path?: string): boolean;
${resetConfiguration}(): void;
// Find in Files Methods
${findInFilesAsync}(pattern: ${IPattern} | string,
folders: null | string | string[],
operation: ${FindInFilesOperation},
params?: { fileMask?: string; flags?: ${FindInFilesFlags}; subExpression?: number }): Promise<${FindInFilesResult}>;
${replaceInFilesAsync}(search: ${IPattern} | string,
replace: ${IPattern},
folders: null | string | string[],
operation: ${ReplaceInFilesOperation},
params?: { fileMask?: string; flags?: ${FindInFilesFlags}; subExpression?: number }): Promise<${FindInFilesResult}>;
${cancelFindInFilesOperation}(): void;
// Process Methods
${findProcess}(processId: number): ${IProcess};
${findProcesses}(name: string): ${IProcess}[];
${openProcess}(process: number | ${IProcess}, withSnapshot = false): ${IProcessWindow};
// Events
${activeDocumentChanged}(handler: (doc: ${IDocument}) => void): number;
${activeDocumentChanged}(eventId: number): void;
${activeViewChanged}(handler: (view: ${IDocumentView}) => void): number;
${activeViewChanged}(eventId: number): void;
}
// This interface is not available in managed environment
// This interface is not available in native environment
readonly apiVersion: number;
// This property is not available in managed environment
// This property is not available in native environment
Returns the current API version. Equals 0x100
in Hex Editor Neo 7.01.
readonly activeDocument: ${IDocument};
// This property is not available in managed environment
// This property is not available in native environment
The reference to the active document's document object. If there is no active document, this property holds null
.
readonly activeView: ${IDocumentView};
// This property is not available in managed environment
// This property is not available in native environment
The reference to the active editor window's document view object. If there is no active window, this property holds null
.
readonly wholeFile: ${ISelection};
// This property is not available in managed environment
// This property is not available in native environment
Returns a special selection object that means “whole file”.
readonly documents: ${IDocument}[];
// This property is not available in managed environment
// This property is not available in native environment
Returns an array of all opened documents in the editor.
readonly activeProcessWindow: ${IProcessWindow};
// This property is not available in managed environment
// This property is not available in native environment
Returns a reference to an active process window or null
if no such window exists.
log(message: any): void;
// This method is not available in managed environment
// This method is not available in native environment
message
Prints the message
to the Console. Does not halt script execution.
log("The value of the parameter v = " + v);
alert(message: any, params?: { title?: string; buttons?: ${AlertButtons}; icon?: ${AlertIcon} }): ${AlertResult};
// This method is not available in managed environment
// This method is not available in native environment
message
params
title
and combinations of buttons
and icon
to use. If title
is omitted, default title is used. If buttons
is omitted, a single OK button is displayed and if icon
is omitted, no icon is displayed ina message box.A button pressed by the user. Should be one of the values of AlertResult enumeration.
Display a message in a message box and return user's choice. Allows the script to customize the window title and buttons and icons used.
if (${AlertResult}.yes === alert("Do you want to execute the sequence of operations", { title: "Overwrite Prompt", buttons: ${AlertButtons}.YesNo, icon: ${AlertIcon}.Question))
{
// ...
}
input(message: string): string;
// This method is not available in managed environment
// This method is not available in native environment
message
The string entered by the user.
Displays a message to the user and asks him to enter the line of text. The method then returns the text returned by the user. The call to this method results in a message box to be displayed.
var name = input("Enter your name:");
log("User name is " + name);
async(handler: () => void, ms: number, repetitive = false): number;
// This method is not available in managed environment
// This method is not available in native environment
handler
ms
milliseconds once or until cancelled, depending on the repetitive
parameter.ms
repetitive
Returns an asynchronous function identifier. You may pass this identifier to cancelAsync method to cancel delayed function.
Schedules a passed Javascript function for delayed execution. A caller may optionally specify if the async function should be repetitive.
TypeScript lambda that is executed once after 1 second:
async(() => alert("Async handler executed"), 1000);
JavaScript function that is invoked every 2 seconds until cancelled after 20 seconds:
var h1 = async(function() { alert("Async handler executed"); }, 2000, true);
async(function() { cancelAsync(h1); }, 20000);
cancelAsync(handlerId: number): void;
// This method is not available in managed environment
// This method is not available in native environment
handlerId
Cancels pending async handler.
JavaScript function that is invoked every 2 seconds until cancelled after 20 seconds
var h1 = async(function() { alert("Async handler executed"); }, 2000, true);
async(function() { cancelAsync(h1); }, 20000);
delay(ms: number): Promise<void>;
// This method is not available in managed environment
// This method is not available in native environment
ms
Returns a Promise
object that gets completed in a given number of milliseconds.
Using await:
async function test() {
// ...
await delay(500);
// ...
}
Using continuations:
delay(500).then(() => { ... });
loadTextFile(path: string): string;
// This method is not available in managed environment
// This method is not available in native environment
path
Loads contents of a text file into a string.
Load text file into string and print it:
log(loadTextFile("c:\\temp\\test.js"));
stopScript(): void;
// This method is not available in managed environment
// This method is not available in native environment
Stops execution of a current script.
createPattern(): ${IPattern};
// This method is not available in managed environment
// This method is not available in native environment
An empty pattern object.
Creates an empty pattern object.
// Replace all occurrences of a "test" pattern with an empty pattern
await activeView.replaceAllAsync(createPattern("test"), wholeFile, createPattern());
createPattern(text: string, encoding?: ${Encodings}): void;
// This method is not available in managed environment
// This method is not available in native environment
text
encoding
parameter specifies how Hex Editor Neo interprets this string.encoding
Create a pattern from a given text string. Optional encoding
parameter specifies how the editor interprets the given string.
createPattern(data: number[], dataType = ${ValueType}.Byte, bigEndian = false): ${IPattern};
// This method is not available in managed environment
// This method is not available in native environment
data
dataType
data
array. Defaults to ValueType.Byte.bigEndian
true
to encode values from the data
array as big-endian values, false
otherwise. Defaults to false
. Does not change data encoding if dataType
equals ValueType.Byte
.Create a pattern from a given number array. Optional dataType
and bigEndian
parameters change how the values in a data array are interpreted.
var pattern = createPattern([0x1234, 0x9876], ValueType.Word, true);
createPattern(data: Uint8Array | Uint16Array | Uint32Array): ${IPattern};
// This method is not available in managed environment
// This method is not available in native environment
data
Create a pattern from a given data. Data is used as-is, without any conversion.
newDocument(format?: string): ${IDocument};
// This method is not available in managed environment
// This method is not available in native environment
format
Optional format for the new document.
Format | Description |
---|---|
"binary" | Create standard empty document. This is the default format. |
"intel-hex" | Create an encoded Intel Hex document. |
"motorola-hex" | Create an encoded Motorola S-Records document. |
A document object for the created document.
Create an empty document. Created document becomes an active document. A single view is also automatically created (it becomes an active view) and is opened in the editor.
var document = newDocument();
log("New document created.");
openFile(path: string, mode = ${OpeningMode}.Normal, readOnly = false, format?: string): ${IDocument};
// This method is not available in managed environment
// This method is not available in native environment
path
mode
readOnly
true
to open a file in read-only mode, false
otherwise. Defaults to false
.format
Optional format. If specified, forces the editor to try to open a file in a given format, overriding default behavior which analyzes the file's extension to determine format.
Format | Description |
---|---|
"binary" | Open as standard binary document. |
"intel-hex" | Open as Intel Hex document. |
"motorola-hex" | Open as Motorola S-Records document. |
Open a given file. If format
is omitted, Hex Editor Neo analyzes file extension to determine the format of the file. .hex
extension switches to the Intel Hex format and .s19
, .s28
and .s37
extensions switch to the Motorola S-Records format.
Created document becomes an active document. A single view is also automatically created (it becomes an active view) and is opened in the editor.
var document = openFile("c:\\temp\\test.bin");
openVolume(path: string, friendlyName?: string, mode = ${OpenVolumeMode}.ReadOnly): ${IDocument};
// This method is not available in managed environment
// This method is not available in native environment
path
friendlyName
mode
Open a given volume (logical disk) in the editor.
Created document becomes an active document. A single view is also automatically created (it becomes an active view) and is opened in the editor.
var document = openVolume("\\\\?\\Volume{7c1102f4-68e7-22e5-a511-80aa6f644963}\\", "Volume: C:\\", OpenVolumeMode.ReadOnly);
openDisk(path: string, friendlyName?: string, readOnly = true): ${IDocument};
// This method is not available in managed environment
// This method is not available in native environment
path
friendlyName
readOnly
true
to open the disk in read-only mode, false
otherwise. If omitted, defaults to true
.Open a given disk (physical disk) in the editor.
Created document becomes an active document. A single view is also automatically created (it becomes an active view) and is opened in the editor.
var document = openDisk("\\\\.\\PHYSICALDRIVE0", "First Physical Disk", true);
openHexAsync(path: string, format: ${HexFormat}, flags = ${InsertHexFlags}.None): ${IDocument};
// This method is not available in managed environment
// This method is not available in native environment
path
null
to take file contents from the Clipboard.format
flags
Open a given encoded hex file in the editor. format
is used to specify the format of the hex file and flags
modify the file decoding behavior.
Created document becomes an active document. A single view is also automatically created (it becomes an active view) and is opened in the editor.
var document = await openHexAsync(null, HexFormat.Intel, InsertHexFlags.IgnoreDataOffset);
activate(value: string | ${IWindow}): void;
// This method is not available in managed environment
// This method is not available in native environment
value
Activates a given window. This method takes a reference to the window to activate or a window name.
activate("New Document 1");
// activate the first view of the first document
activate(documents[0].views[0]);
closeAll(closeMode = ${CloseMode}.Prompt): boolean;
// This method is not available in managed environment
// This method is not available in native environment
closeMode
true
if operation was successful, false
otherwise.
Close all opened windows. The optional closeMode
parameter is interpreted as follows:
Value | Description |
---|---|
Prompt | Ask the user what to do with unsaved changes to documents. |
Save | Force save any unsaved changes. |
Discard | Discard all unsaved changes. |
displaySettings(page?: string, hideOtherPages = false): void;
// This method is not available in managed environment
// This method is not available in native environment
page
hideOtherPages
true
to hide all other pages besides page
, false
otherwise.Display the application Settings Window, optionally highlighting a given settings page.
exportSettings(path?: string): boolean;
// This method is not available in managed environment
// This method is not available in native environment
path
true
if the export was successful and false
otherwise.
Exports all application settings to a given file. If a full path is not given, an Save File window opens so the user may select the location of the export file.
importSettings(path?: string): boolean;
// This method is not available in managed environment
// This method is not available in native environment
path
true
if the import was successful and false
otherwise.
Imports all application settings from a given file. If a full path is not given, an Open File window opens so the user may select the location of the file.
restart(message?: string): void;
// This method is not available in managed environment
// This method is not available in native environment
message
Restart Hex Editor Neo. Optional message
, if specified, is displayed to the user before proceeding with a restart.
exportConfiguration(path?: string): boolean;
// This method is not available in managed environment
// This method is not available in native environment
path
true
if the export was successful and false
otherwise.
Exports the current UI configuration (toolbars and tool window layout) to a given file. If a full path is not given, an Save File window opens so the user may select the location of the export file.
importConfiguration(path?: string): boolean;
// This method is not available in managed environment
// This method is not available in native environment
path
true
if the import was successful and false
otherwise.
Imports UI configuration (toolbars and tool window layout) from a given file. If a full path is not given, an Open File window opens so the user may select the location of the file.
resetConfiguration(): void;
// This method is not available in managed environment
// This method is not available in native environment
Resets the UI configuration to default state.
findInFilesAsync(pattern: ${IPattern} | string,
folders: null | string | string[],
operation: ${FindInFilesOperation},
params?: { fileMask?: string; flags?: ${FindInFilesFlags}; subExpression?: number }): Promise<${FindInFilesResult}>;
// This method is not available in managed environment
// This method is not available in native environment
pattern
folders
params.flags
include the FindInFilesFlags.IncludeSubFolders flag, sub-folders of a given folder(s) are also searched. If folders
parameter is null
, the operation is performed for opened documents only.operation
params
fileMask
, if omitted, defaults to "*"
. flags
, if omitted, equals to FindInFilesFlags.None.A Promise
object that produces a result of operation (as FindInFilesResult object) when completed.
Start the Find in Files operation. folders
parameter specifies the starting search location. pattern
specifies the pattern to search. The behavior of this method changes depending on the type of this parameter:
Type | Description |
---|---|
IPattern | Standard matching mode is used. params.flags parameter may include the FindInFilesFlags.IgnoreCase flag to ignore patter case when matching. |
string | Regular expression mode is used. params.flags parameter may include the FindInFilesFlags.IgnoreCase and FindInFilesFlags.RegularExpressionUnicode flags. Optional params.subExpression , if set, specifies the regular expression's sub-expression to use. |
replaceInFilesAsync(search: ${IPattern} | string,
replace: ${IPattern},
folders: null | string | string[],
operation: ${ReplaceInFilesOperation},
params?: { fileMask?: string; flags?: ${FindInFilesFlags}; subExpression?: number }): Promise<${FindInFilesResult}>;
// This method is not available in managed environment
// This method is not available in native environment
search
replace
folders
params.flags
include the FindInFilesFlags.IncludeSubFolders flag, sub-folders of a given folder(s) are also searched. If folders
parameter is null
, the operation is performed for opened documents only.operation
params
fileMask
, if omitted, defaults to "*"
. flags
, if omitted, equals to FindInFilesFlags.None.A Promise
object that produces a result of operation (as FindInFilesResult object) when completed.
Start the Replace in Files operation. folders
parameter specifies the starting search location. pattern
specifies the pattern to search. The behavior of this method changes depending on the type of this parameter:
Type | Description |
---|---|
IPattern | Standard matching mode is used. params.flags parameter may include the FindInFilesFlags.IgnoreCase flag to ignore patter case when matching. |
string | Regular expression mode is used. params.flags parameter may include the FindInFilesFlags.IgnoreCase and FindInFilesFlags.RegularExpressionUnicode flags. Optional params.subExpression , if set, specifies the regular expression's sub-expression to use. |
cancelFindInFilesOperation(): void;
// This method is not available in managed environment
// This method is not available in native environment
Cancel a currently running Find in Files operation.
findProcess(processId: number): ${IProcess};
// This method is not available in managed environment
// This method is not available in native environment
processId
A reference to a running process or null
if there is no such process
Locate the running process object using the provided process ID.
findProcesses(name: string): ${IProcess}[];
// This method is not available in managed environment
// This method is not available in native environment
name
An array of running process objects. If no match is found, the returned array is empty.
Find all instances of a running processes that match the provided name. Name matching is case insensitive.
openProcess(process: number | ${IProcess}, withSnapshot = false): ${IProcessWindow};
// This method is not available in managed environment
// This method is not available in native environment
process
withSnapshot
A reference to a created process window object.
Opens the given process and returns its process window object.
activeDocumentChanged(handler: (doc: ${IDocument}) => void): number;
activeDocumentChanged(eventId: number): void;
doc
null
.This event is fired when the active document changes.
activeViewChanged(handler: (view: ${IDocumentView}) => void): number;
activeViewChanged(eventId: number): void;
view
null
.This event is fired when the active view changes.