Navigation: For Developers > Extend Functionality with HEScript >

UserMain Script And Script Templates

 

 

 

 

In this topic we'll explore pre-defined HEScript scripts, including the UserMain script, and delve into their global application events.

 

About the UserMain Script

 

The UserMain script is an integral part of every project initiated with HTML Executable. It plays a pivotal role by housing numerous global events that enable you to inject special commands and tailor your application's behavior.

 

 

Here are some key events provided by the UserMain script:

 

OnBeforeNavigate (NewURL, TargetFrame: String): Boolean

 

This event triggers just before the application displays an HTML page. You can set the result to True to halt the operation. NewURL represents the full URL to be displayed, and TargetFrame denotes the frame where the page appears, if any.

 

OnNavigateComplete (URL: String)

 

It fires when a page has finished loading. URL represents the full URL of the loaded page.

 

OnPubLoaded: Boolean

 

This event occurs when the application starts, just before displaying the homepage. Set Result to True if you wish to exit immediately without any warning.

 

OnPubBeingClosed

 

Triggered when the application is about to terminate.

 

OnStartSearching (what: String);

 

When a full search is initiated. "what" contains the exact user query.

 

OnDisplayWindow (WindowName: String)

 

This event comes into play when a window, specified by WindowName, is displayed. It applies to both main and secondary windows, including pop-ups.

 

OnStartMainWindow

 

Occurs just before the main window is displayed, right before showing the homepage.

 

OnMinimizeToTray

 

When the main window is minimized to tray.

 

OnRestoreFromTray

 

When the main window is restored from tray.

 

OnCloseWindow (WindowName: String)

 

This event triggers when a user closes a window.

 

OnWindowCloseQuery (WindowName: String): Boolean

 

If a user attempts to close a window, this event is called. You can set Result to False to prevent the window from closing, or True to allow it. Note that this event is not created by default and must be added manually to the UserMain script.

 

OnTimer (TimerName: String): Boolean

 

This event is triggered by a timer created using the StartTimer HEScript function. It activates when a specified amount of time, determined by the StartTimer function, elapses. Set the result of this function to True if you want to disable the timer or use StopTimer to achieve the same result.

 

OnInvalidPasswordAtStartup: Boolean

 

This event occurs when an invalid global password is provided at startup. Set to True if you prefer the application not to display an error message and exit.

 

OnExpiredPublication: Boolean

 

Triggers when the global expiration date is reached. Set to True if you wish to bypass error messages and exit.

 

OnKeyNotValidated: Boolean

 

Occurs when the validation of a registration key failed. Set to True if you want the application to exit.

 

OnKeyValidation: Boolean

 

Lets you decide whether validation of the registration key should be performed at startup or not. Set Result to True if you want the publication to be validated, False otherwise.

 

OnPDFDisplay(PDFPath: String)

       

This event is called when the PDF viewer loads and displays the PDF whose path is given by PDFPath. Only for the built-in PDF viewer.

 

OnTrayIconClick / OnTrayIconDblClick

 

This event is called when the user clicks / double-clicks the tray icon.

 

OnWebUpdateNewVersionFound: Boolean

 

This event occurs when a new version is detected by the web update feature at publication startup. Set Result to True if you do not want the Web Update dialog box to be displayed and perform actions yourself

     

OnPrintPage

 

Fires when the user prints the current page.

 

OnFullScreenModeChange(FullScreen: Boolean);

    

Signal a change in full-screen mode, where FullScreen indicates whether full-screen mode is enabled (true) or disabled (false).

Use this to show or hide your custom controls thanks to the SetUIProp HEScript function.

 

Explore more about scripting in HTML Executable:

 

  Introduction to Scripting

 

  Using the Script Manager

 

  Script Function Reference