newObjects IE ScriptBar Toolbar utility functions (Host object)
These functions and properties are accessible for the toolbar script through the namespace Host. I.e. you can only call them from the script that runs in the background. to call one of them you refer to it like in this example:

Set o = Host.CreateObject("newObjects.utilctls.SFMain")
' Creates object
Host.MsgBox "Hello World!"
' Shows a message box

So the Host keyword represents the ScriptBar object which hosts your script (from that comes the name Host for the namespace).

Functions provided by the Host are:

CreateObject

If you are familiar with ASP this is like Server.CreateObject in it. The method creates a COM object by ProgID or ClassID.
Syntax:
Set o = Host.CreateObject(id_string)
Parameters:
id_string - is a ProgID of the object you want to create e.g. "newobjects.utilctls.SFMain" or "ADODB.Connection" or "newObjects.sqlite.dbutf8" and so on. It can be also a ClassID string - e.g. "{27917F02-97BC-4e88-AB7F-173E5E885FAC}" (instead of "newObjects.sqlite.dbutf8") or "{F86AC6C2-5578-4AE8-808A-DC5DAA78082A}" instead of "newobjects.utilctls.SFMain" and so on. You can find the ProgID-s/ClassID-s of the objects you need from their documentation.

The newObjects ScriptBar ships with newObjects ActiveX Pack1 family which provides a lot of classes you can use to implement your script - see: AXPack1 core (file access, dictionary objects, threads and many others), NetStreams (TCP/IP and IRDA), SQLite COM (SQL database engine independent of ADO). These libraries are included with the toolbar installation by default and you can use them without further concerns about their availability.

Remarks: Host.CreateObject also supports composite objects creation directly from file (COM objects written in script) which you can create yourself.

MsgBox

This function shows a message box to the user.
Syntax:
r = Host.MsgBox(msg [, capt [, flags]])
Parameters:
msg - the text in the message box
capt - the caption of the message box (optional)
flags - details about the message box (optional) - see the possible combinations below.
result: depends on the flags. If you want only to show a message it can be ignored.

The flags allow you configure what buttons will be shown in the message box and what values will be returned depending on what will the user do. This value is directly passed to the Win32 MessageBox function and you can see all the supported values in MSDN topic about it. Some of the most useful combinations are listed below:
0 - (default) OK button only
1 - OK and Cancel buttons. Returns: OK=1, Cancel=2
3 - Yes, No and Cancel buttons. Returns: Yes=6,No=7,Cancel=2
4 - Yes and No buttons. Returns: Yes=6, No=7
By adding to the above value:
16 - Stop icon is shown
32 - Question icon is shown

Example:
If Host.MsgBox("What to continue?","Message",4) = 7 Then
  ' Cancel the action
End If

Execute

Opens document, starts application and so on.
Syntax:
b = Host.Execute(verb,app [,cmdline [,workdir [,showcmd]]])
Parameters:
verb - the verb as defined by Win32 ShellExecute method. Can be "open", "print" or other supported verb. Most often "open" is used to indicate the default open action.
app - Full path to an application or document. If a document is specified (for example a MS Word document) you can use any suitable verb in the previous parameter, if an application is specified use "open" for a verb.
cmdline - If the app points to an application this parameter can be used to pass command line parameters to it. For example if you want to open certain document with application you specify you can point the application in the app parameter and put the document path in cmdline parameter..
workdir - If the app parameter specifies an application it may be important to run it in a particular directory. This can be set in this parameter.
showcmd - By default the document or the application specified are opened in normal window (1). If you want to force them maximized (3) or minimized (2) for example you can use this parameter.

Remarks: This method passes the control almost directly to the Win32 ShellExecute function. Some more details can be found in the MSDN topic about it. The return result indicates if the operation is successful.

Timeout

This function sets a timeout. After the timeout expiration an OnTimeout event is fired to the toolbar script.
Syntax:
id = Host.Timeout(seconds)
Parameters:
seconds - the length of the timeout in seconds.
Returned value: is the id of the timeout.

Remarks: Each timeout corresponds to one OnTimeout event fired after the specified number of seconds. The id returned by the function is also passed to the OnTimeout event handling function in order to allow the toolbar script to identify which timeout has expired. If the logic of the application requires that the timeout must be cancelled it can use the DiscardTimeout function to cancel it (if discarded before expiration the event for this timeout is not fired). If you need an event that occurs regularly you need to set new timeout after the first one expires.

DiscardTimeout

Discards a timeout previously set by its id.
Syntax:
Host.DiscardTimeout id
Parameters:
id - the id of the timeout to discard.

Remarks: Each call to Host.Timeout creates a new timeout with unique id. You need to record its id in order to recognize it when you sink events by receiving calls to your OnTimeout function or when you need to discard it before it expires.

Menus

Returns the VarioMenu root object. The application creates menu definitions through that object.

Syntax:
Set menus = Host.Menus

The VarioMenu object returned has only one property in the current version - MenuTree. Under that property the VarioMenu system allows you create and change dynamically collections of VarioMenuItem-s. The VarioMenuItem objects may represent single menu item or a sub-menu. Therefore the application maintains a tree of menu branches under the Host.Menus.MenuTree property. They can be nested as deep as needed. Any branch except the root (Host.Menus.MenuTree) can be passed to the DisplayPopupMenu finction and shown at any time. 

See the IE ScriptBar Menus for detailed description and examples. For the VarioMenu in-depth information see the VarioMenu topics. 

DisplayPopupMenu

Displays a popup menu at the specified location.

Syntax:
Host.DisplayPopupMenu(menu, x, y [,flags])
Parameters:
menu - A menu branch (a pop-up) from the menu tree. For example Host.Menus.MenuTree("MyMenu").
x, y - The absolute screen coordinates at which the menu will be shown. The application is responsible to calculate the coordinates.
flags - Optional flags. These flags are rarely needed, through them you can specify the menu alignment and some preferences about its placement in case there is not enough space for it on the screen. More than one flag can be passed - use bitwise Or to combine the flags (flag1 Or flag2 in VBScript and flag1 | flag2 in JScript). The supported flags are (in VBScript notation, all the values are hexdecimal):
Const MENU_LEFTBUTTON = &H0000
Const MENU_RIGHTBUTTON = &H0002

Specifies with which mouse button the menu items can be clicked.

Const MENU_LEFTALIGN = &H0000
Const MENU_CENTERALIGN = &H0004
Const MENU_RIGHTALIGN = &H0008

The menu horizontal alignment relative to the specified screen coordinates.

Const MENU_TOPALIGN = &H0000
Const MENU_VCENTERALIGN = &H0010
Const MENU_BOTTOMALIGN = &H0020

The menu vertical alignment relative to the specified screen coordinates.

Const MENU_HORIZONTAL = &H0000
Const MENU_VERTICAL = &H0040

The auto alignment preferences. Apply only when the available screen space doesn't allow the menu to display on the specified coordinates. In such a case the system chooses automatically how to place the menu and these flags specify which methods should be preferred. 

' Not actualy useful for the ScriptBar
Const MENU_RECURSE = &H0001

' Windows 98/2000 and later only
' Depends on the system settings
Const MENU_HORPOSANIMATION = &H0400
Const MENU_HORNEGANIMATION = &H0800
Const MENU_VERPOSANIMATION = &H1000
Const MENU_VERNEGANIMATION = &H2000
Const MENU_NOANIMATION = &H4000

' Windows XP/2003 and later - right to left
' Warning! this will fail and the menu would not show if it is not in a RTL language
Const MENU_LAYOUTRTL = &H8000

For more information and examples see the IE ScriptBar Menus.

newObjects Copyright 2001-2006 newObjects [ ]