HEScript is specially designed to control application behavior and communicate with the Windows environment.
There are many internal functions that can be called from your HEScript procedures and functions.
Notes:
- Many internal functions are not listed here, as they may be used, for instance, in system HTML pages. Please ignore them or contact us for more information.
- You can find additional Object Pascal references at delphibasics.co.uk.
Interface Functions #
| Function Name | Description & Prototype | Parameters, Example, Remarks |
|---|---|---|
| MessageBox | Displays a message box (similar to the Windows API MessageBox).function MessageBox(const Text, Title: String; const Flags: Integer): Integer; |
|
| MessageDlg | Displays a themeable message box. function MessageDlg(const Message, Title: String; DialogType: TMsgDlgType; Buttons: TMsgDlgButtons): Integer; |
Note: This function should not be called during the initialization event or when the application exits. |
| SetUIProp | Sets the value of a specified property for a control. procedure SetUIProp(const id, propname, propval: String); |
|
| GetUIProp | Gets the value of a specified property for a control. function GetUIProp(const id, propname: String): String; |
|
| ChangeStatusBar | Sets the text of the status bar. procedure ChangeStatusBar(const Text: String; Reset: Boolean); |
|
| ShowAboutBox | Shows the About box. procedure ShowAboutBox; | |
| ManageWaitForm | Shows or hides a “Please wait…” dialog box. procedure ManageWaitForm(Show: Boolean; Text: String); |
After calling |
Navigation Functions #
| GoToPage | Displays or executes the specified URL. procedure GoToPage(const Name, Window: String); |
|
| ExitPublication | Terminates the application. procedure ExitPublication; | |
| NavigateCommand | Executes a standard navigation command. procedure NavigateCommand(const Command: Integer); | Command can be: 0 (Back), 1 (Forward), 3 (Copy), 4 (Select All), 5 (Paste), 6 (Zoom In), 7 (Zoom Out), 9 (Cut), 10 (View Source), 11 (Delete), 12 (Dev Tools), 13 (Update Preferences). |
| ExecuteLiveHEScript | Compiles and executes HEScript code at runtime. function ExecuteLiveHEScript(const Code: String): String; | The Code must be a complete block, including begin and end;. |
| ExecutePHPScript | Executes PHP code and optionally returns the output. function ExecutePHPScript(const PHPCode: String): String; | The PHPCode must include the <?php and ?> tags. |
| ExecuteHTMLScript | Executes a JavaScript function in the current HTML page. procedure ExecuteHTMLScript(const CommandLine, scriptURL: String); | CommandLine is the script function to call, including arguments. |
Management Functions #
| SetGlobalVar | Sets the value of a global variable. procedure SetGlobalVar(const Name, Value: String; const IsStored: Boolean); | IsStored: If True, the variable is persistent (saved and restored on next run). |
| GetGlobalVar | Gets the value of a global variable. function GetGlobalVar(const Name, DefaultIfNotFound: String): String; | Returns DefaultIfNotFound if the variable doesn’t exist. |
| GetString | Returns the value of a resource string. function GetString(const ID: String): String; | Returns the value of the resource string, or empty if not found. |
| GetManualHardwareID | Returns a unique system ID based on hardware specs. function GetManualHardwareID(method: integer): String; | method: 0 (HDD Serial), 1 (Media ID), 2 (CPU ID), 3 (HDD Manufacturer ID). |
Program, File, and Folder Functions #
| OpenFile | Opens an external document or program file. function OpenFile(const Filename, Parameters: String; State: Integer): Integer; | Result is successful if greater than 31. |
| UnpackTemporaryResource | Extracts a compiled file to a temporary file and returns the path. The file is removed when the application closes. function UnpackTemporaryResource(const SourceName: String): String; | Useful with OpenFile for files that can’t be handled internally (videos, etc.). |
| RunAProgram | Executes the specified program file. function RunAProgram(const Filename, Params, WorkingDir: String; Wait: Boolean; DispWindow: Integer): Boolean; | Wait: If `True`, the application waits for the program to finish. |
| OpenFileDialog | Displays the standard “File Open” dialog box. function OpenFileDialog(const aTitle, aFilename, aDefaultExt, aFilter, aInitialDir: String): String; | Returns the full path to the selected file, or an empty string if canceled. Warning: The main window must be available. |
| SaveFileDialog | Displays the standard “File Save As” dialog box. function SaveFileDialog(const aTitle, aFilename, aDefaultExt, aFilter, aInitialDir: String): String; | Returns the full path to the selected file, or an empty string if canceled. Warning: The main window must be available. |
| SelectDirectory | Displays a “Browse For Folder” dialog box. function SelectDirectory(const Caption: String; const Root: String): String; | Returns the full path to the selected folder, or an empty string if canceled. |
Miscellaneous Functions #
| MD5OfAString | Computes the MD5 hash of a string (converts to UTF-8 first). function MD5OfAString(const Str: String): String; | |
| InputBox | Prompts the user for input with a dialog box. function InputBox(const Query, Title, Default: String): String; | Returns the user’s input, or an empty string if they chose “Cancel”. |
| StartTimer | Starts a timer to trigger an event after a specified interval. procedure StartTimer(const TimerName: String; const Interval: Cardinal); | Interval is in milliseconds (e.g., 1000 for one second). |
| StopTimer | Stops a timer started by StartTimer.procedure StopTimer(const TimerName: String); |
Delphi Class Support #
Some Delphi classes, such as TStringList and TMemoryStream, are also supported.
To use these classes, you must add the Classes unit to the uses clause at the top of your script:
uses Classes;To use the TRegistry object, add the Registry unit:
uses Registry;
procedure Test1;
var
reg: TRegistry;
begin
reg := TRegistry.Create;
reg.RootKey := HKEY_LOCAL_MACHINE;
reg.DeleteKey("Software\HEViewer\Coucou");
reg.CloseKey();
reg.Free;
end;Other Windows dialog boxes, such as the Color Picker dialog, are also available through the script engine if you add the Dialogs unit:
uses Dialogs;
procedure StartIt;
var
CD: TColorDialog;
S: String;
begin
CD := TColorDialog.Create(nil);
if CD.Execute(0) then
begin
S := inttostr(CD.Color);
ShowMessage(S);
end;
CD.Free;
end;