../Window(s) webview/ScriptingHome
WebView: Scripting
All webview .htt files have scripts, let it be for resizing the icon area with the window size or for retrieving information about the selected files and more.
To help this, special objects can be accessed through scripting (RO indicates Read-only):
This section gives reference to all scripted object used in the webview. To see where/how it is used I would suggest you look at the scripting parts of the .htt files, reproduced here.
 
The FileList object
The FileList object is the icon area usually shown on the right part of the webview. "FileList" is a unique ID for a ShellFolderView object, that represents the objects in a view.
It is included inside the .htt file's code (at the end) as: <object id=FileList classid="clsid:1820FED0-473E-11D0-A96C-00C04FD705A2" [...] >
</object>
See its position in [ 98 - Me ] Folder.htt file.
The FileList object has a few parameters, but I don't think they work really well. <object id=FileList classid="clsid:1820FED0-473E-11D0-A96C-00C04FD705A2" [...] >
 <param name="Location" value="%THISDIRPATH%\folder">
 <param name="AlignLeft" value="1">
 <param name="AutoSize" value="7">
 <param name="AutoSizePercentage" value="100">
 <param name="AutoArrange" value="1">
 <param name="NoClientEdge" value="true">
 <param name="ViewMode" value="3">
</object>
The parameter values of the FileList control affect the following settings:
  • Location defines the path to the folder to be displayed.
  • AlignLeft/AlignRight defines the alignment of the items when displayed.
  • AutoSize. Leave this value set to 7.
  • AutoSizePercentage. Leave this value set to 100.
  • AutoArrange. A value of 0 allows items displayed in Large Icon or Small Icon views to be moved, while a value of 1 enforces autoarrange at all times.
  • NoClientEdge defines whether or not the control will have a visible border.
  • ViewMode defines the view in which the contents of the folder will be displayed (1=Large Icons, 2=Small Icons, 3=List, 4=Details).
The Filelist object does not resize itself with a percentage value but has to be resized by scripting its style properties style.pixelWidth / style.Width and style.pixelHeight / style.Height This is done by the Resize() and FixSize() functions, in Me/2k/XP and 98 respectively.
The ShellFolderView object
The ShellFolderView object represents the objects in a view. There are properties and methods used to obtain information about the contents of the view. "FileList" is usually a unique ID for it in webviews.
Here is its useful properties, methods and events, for more go to the MSDNLib:

Properties
  • FocusedItem: object.FocusedItem Contains a FolderItem object (one item) that represents the item that has the focus. RO.

  • Folder: object.Folder Contains a Folder object that represents the view. RO. Here: FileList.Folder
Methods
  • PopupItemMenu: object.PopupItemMenu( vItem, [vx], [vy] ) Me/2k/Xp. Creates a shortcut menu for an item and returns the selected command string. vItem is the FolderItem object for which the shortcut menu will be created. vx and vy are the horizontal and vertical position of the menu, in screen coordinates.

  • SelectedItems: object.SelectedItems() Retrieves a FolderItems object that represents all of the selected items in the view.

  • SelectItem: object.SelectItem( vItem, dwFlags ) Sets the selection state of an item ("vItem") in the view (!). Problem here is you'll maybe have to loop all the items you want to change the selection state off.
    "dwFlags" is a set of flags that indicate the new selection state of an item (0: Deselect, 1: Select, 3: Rename mode, 4: Deselect all but the specified item, 8: Ensure the item is displayed in the view, 16: Give focus).
Events
  • SelectionChanged: object_SelectionChanged Occurs when the selection state of any item or items in the view has changed.

  • VerbInvoked: object_VerbInvoked Occurs when a Verb is invoked in the FileList.

  • BeginDrag: object_BeginDrag Occurs when an item is being dragged in the FileList.
The Folder Object
The Folder object is very important, you can use it to retrieve lots of properties, using FileList.Folder It was updated to the Folder2 object in the 5th version of Shell32.dll, and extends the Folder object to support offline folders with additional properties and methods (this CSC thing).
Here is its useful properties and methods, for more go to the MSDNLib:

Properties
  • ParentFolder: object.ParentFolder The parent Folder object. RO.

  • Title: object.Title The title of the folder. RO.
Methods
  • CopyHere: object.CopyHere( vItem, [vOptions] ) Copies an item or items ("vItem") to the folder represented by the folder object. vItem can be a file name string, a FolderItem object, or a FolderItems object. vOptions specifies options for the copy operation. More info.

  • GetDetailsOf: object.GetDetailsOf( vItem, iColumn ) Retrieves information about an item ("vItem") in a folder represented by the folder object. vItem specifies the item (FolderItem object) for which to retrieve the information (also, using a null value will return the detail type string, ex "Size: "). iColumn is an integer value that specifies the information to be retrieved (0: name, 1: size, 2: type, 3: last modified date and time, 4: attributes (Me/2k/Xp only), -1: info tip). Used in the ShowInfo() function in Me/2k/Xp and in the SelectionChanged routine in 98.

  • Items: object.Items() Retrieves a FolderItems object that represents the collection of items in the folder.

  • MoveHere: object.MoveHere( vItem, [vOptions] ) Moves an item or items ("vItem") to the folder represented by the folder object. vItem can be a file name string, a FolderItem object, or a FolderItems object. vOptions specifies options for the move operation. More info.

  • NewFolder: object.NewFolder( bName ) Creates a new folder with bName as the name of the new folder.
The FolderItems Object (/Collection)
The FolderItems object represents a collection of items in a Shell folder. You can use it to get a list of the folder items for example. It was updated to the FolderItems2 object in the 5th version of Shell32.dll, and extends the FolderItems object to supports one additional method, InvokeVerbEx Here is its useful properties and methods, for more go to the MSDNLib:

Properties
  • Count: object.Count The number of items in the collection. RO.

  • Parent: object.Parent The parent object of the collection. RO.
Methods
  • Item: object.Item( n ) Retrieves the FolderItem object for the 'n'th item in the collection (starting at 0).

  • InvokeVerbEx: object.InvokeVerbEx( [vVerb] [,vArgs] ) (FolderItems2: Me/2k/Xp) Executes a verb on a collection of FolderItem objects. vVerb is a variant with the verb string that corresponds to the command to be executed. If no verb is specified, the default verb is executed. vArgs is a variant that consists of a string with one or more arguments to the command specified by vVerb. The format of this string depends on the particular verb.
The FolderItem Object
The FolderItem object represents an item in a Shell folder. Here is its useful properties and methods, for more go to the MSDNLib:

Properties
  • GetFolder: object.GetFolder If the item is a folder, contains the item's Folder object. RO.

  • GetLink: object.GetLink If the item is a shortcut, contains the item's IShellLink object. RO.

  • IsBrowsable: object.IsBrowsable Indicates if the item can be browsed (returns true else false). RO.

  • IsFileSystem: object.IsFileSystem Indicates if the item is part of the file system (returns true else false). RO.

  • IsFolder: object.IsFolder Indicates if the item is a folder (returns true else false). RO.

  • IsLink: object.IsLink Indicates if the item is a shortcut (returns true else false). RO.

  • ModifyDate: object.ModifyDate The date and time that the item was last modified. Equivalent to Folder.GetDetailsOf( vItem, 3 )
  • Name: object.Name The item's name. Equivalent to Folder.GetDetailsOf( vItem, 0 )
  • Parent: object.Parent The item's parent object. RO.

  • Path: object.Path The item's full path and name. RO.

  • Size: object.Size The item's size, in bytes. RO. Equivalent to Folder.GetDetailsOf( vItem, 1 )
  • Type: object.Type A string representation of the item's type. RO. Equivalent to Folder.GetDetailsOf( vItem, 2 )
Methods
  • InvokeVerb: object.InvokeVerb( vVerb ) Executes an item's verb. A verb is a string used to specify a particular action that an item supports. Invoking a verb is equivalent to selecting a command from an item's shortcut menu. This is executing an action defined by the verb ("vVerb"), for example &Open (the ampersand is required and just before the O to make it underlined).

  • Verbs: object.Verbs() (Me/2k/Xp only) Retrieves the item's FolderItemVerbs object. This object is the collection of verbs that can be executed on the item.
FolderItemVerbs object (/Collection) (Me/2k/Xp only)
A verb is a string used to specify a particular action that an item supports. The FolderItemVerbs object represents the collection of verbs for an item in a Shell folder.
Here is its useful properties and methods, for more go to the MSDNLib:

Properties
  • Count: object.Count The number of verbs in the collection. RO.

  • Parent: object.Parent The parent object of the collection. RO.
Methods
The FolderItemVerb object (Me/2k/Xp only)
The FolderItemVerb object represents a verb or commands to which an item in a Shell folder responds.
Here is its useful properties and methods, for more go to the MSDNLib:

Properties
  • Name: object.Name The verb's name. RO.

  • Parent: object.Parent The parent object of the collection. RO.
Methods
  • DoIt: object.DoIt() Executes a verb on the FolderItem associated with the verb.
The WebViewFolderIcon object
The WebViewFolderIcon object, or (Folder)Icon, extracts and displays the folder's icon that is displayed in the top left corner of the window.
It is included inside the .htt file's code (at the end) as: <object id=FolderIcon classid="clsid:E5DF9D10-3B52-11D1-83E8-00A0C90DC849" tabIndex=-1>
    <param name="scale" value=100>
</object>
See its position in [ 98 - Me ] Folder.htt file.

The parameter values of the FolderIcon control affect the following settings: scale Sets the scale of the extracted icon in percent.
The Thumbnail/PieChart object
The Thumbnail object is used to show the image preview of many type of files including jpg, gif, bmp, html variations and drive info. It is shown when selecting a supported file, usually underneath its description.
It is included inside the htt file's code (at the end) as: <object id=Thumbnail classid="clsid:1D2B4F40-1F10-11D1-9E88-00C04FDCAB92" [...]>
</object>
See its position in [ 98 - Me ] Folder.htt file.

Properties
  • TotalSpace: object.totalSpace When a drive is displayed, returns a total drive space string (that already formated). RO.

  • UsedSpace: object.usedSpace When a drive is displayed, returns a total drive space string (that is already formatted). RO.

  • FreeSpace: object.freeSpace When a drive is displayed, returns a total drive space string (that is already formatted). RO.
Methods
  • DisplayFile: object.displayFile( sItemPath ) Initiates the thumbnail to show the Item with sItemPath as a path, returns true if done.

  • HaveThumbnail: object.haveThumbnail() Forces the Thumbnail to regenerate itself, returns true if done.
Events
  • OnThumbnailReady: object_OnThumbnailReady Occurs when the Thumbnail has finished the loading of the media file, and is ready to be shown.
The (Media)Player object
The Media player gives a media preview of videos and sounds and is created dynamically by scripting. In 98 the wantmedia var at the beginning of the .htt file must be enabled for it to be shown.
It is included inside the .htt file's code (in the script part) as: <object id="MediaPlayer" classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95" [...]>
    <param name="ShowDisplay" value="false">
    <param name="AutoPlay" value="false">
    <param name="FileName" value="Path">
    <param name="BorderStyle" value="0">
</object>
The parameter values of the MediaPlayer control affect the following settings:
ShowDisplay ? AutoPlay makes the player directly play the media file on load. FileName is the file played, but the Open() method seems better to use. BorderStyle is the border style of the player, [0: no border, ...?].
Properties
  • EnableContextMenu: object.EnableContextMenu Indicates if the media player can display a context menu when right-clicked (true else false).
Methods
  • Open: object.Open( sItemPath ) Opens the file with sItemPath as a path.

  • Stop: object.Stop() Stops the media player.
ActiveX objects (including W.S.H.)
You can also do alot of things by creating/calling ActiveX objects, to manipulate excel sheets, text files etc.. or along with another technology called W.S.H. (Windows Script Host). You can create some of the objects using this synthax: <script type="text/vbscript">
Set objectName = CreateObject( "Object" )
</script>
or <script type="text/javascript">
var objectName = new ActiveXObject("Object");
</script>
In particular, the "Scripting.FileSystemObject" object allows to access file properties. More info found at the MSDNLib. Check also the MS Office Applications Objects, to manipulate Office applications, for example "Excel.Applications" for Excel.

To use WSH (to run apps for example), replace Object by "WScript." plus any of these, especially the last ones (".Shell", ".Network"...).

Check the Html in the UI and Shortcutting syntax pages for more info about WSH/ActiveX (about the ActiveX confirmation dialog in particular).
Object/Clsid table
 
FileList (ShellFolderView) 1820FED0-473E-11D0-A96C-00C04FD705A2
WebViewFolderIcon E5DF9D10-3B52-11D1-83E8-00A0C90DC849
Thumbnail / PieChart 1D2B4F40-1F10-11D1-9E88-00C04FDCAB92
MediaPlayer 22D6F312-B0F6-11D0-94AB-0080C74C7E95
Related
Top

xhtml 1.1