Your DesktopX Documentation Resource Guide

Documentation Home

Quick Start

User's Guide

Developer's Guide

Resources

Tutorials


By now you should realize just w

Object namespace

This section defines the scripting commands that can be applied to objects in DesktopX.

Object.States namespace

From the object namespace you can access the States namespace to read/write state specific properties. States properties also exist in the Object namespace. There are basically three different methods you can use to read/write:
Object.property – it’ll read/write the state property for the current state
Object.States(“mystate1”).property - it’ll read/write the state property for the “mystate1” state
Object.States(“”).property – it’ll write the property to all states in the object

Unless the object has only one state, it is usually better to use the second method.

All properties which can be applied in the States namespace as well as in the Object namespace are suffixed with *
 

Object.Name
Object.Parent
Object.Visible

Through use of these commands you can set an objects name, though it is more likely you will want to retrieve the name of an object or its parent. Object.Parent is used to retrieve the entire object model of the parent, so you can refer to the object. In addition to this, you can also set an object’s parent using this property.
The 'Visible' property is most useful allowing you to show or hide an object without the use of popups or messaging.
Examples:

 

1) MsgBox "This object is called " & Object.Name
2) Msgbox "This object's parent is " & Object.Parent.Object.Name
3) Object.Parent = DesktopX.Object("Some object")
4) DesktopX.Object("AnObject").Parent = DesktopX.ScriptObject("anotherobject")
5) Object.Visible = False

Object.Clone
Object.Delete

This allows you to either duplicate or delete the specified object. When duplicating an object you need to provide the name for the new object and the x and y coordinates where it will be placed. Deleting objects may be useful for things like deleting temporary objects such as instructions once the user has taken note of them.

Examples:

Object.Clone "myobject", 300, 200
If Msgbox("Delete object", vbYesNo) = vbYes Then Object.Delete

Object.Top, Object.Bottom, Object.Left, Object.Right, Object.Move, Object.Rotation (and Object.States("name").Rotation)

With these positioning properties, you can explicitly set or retrieve the location of one side of the object.
If you want to reposition an object, the most efficient was to do it is via 'Move' To do this you specify x and y coordinates in pixels of where you want to place the object.
You can also rotate an object using Object.Rotation.

Examples:

Object.Top = 500
Object.Move 500,200

For x = 1 To 10
Object.Rotation = x*36
Object.Sleep 200
Next

Object.Height, Object.Width

With this command you can retrieve or redefine the actual height and width of the object. Obviously this will stretch the graphic used until it reaches this size.

Examples:

Object.Height = 120
Object.Width = Object.Width * 2

Object.Resize

With this command you can quickly and easily resize an object in one command rather than setting width and height individually.

Examples:

Object.Resize 100,300
Object.Resize Object.Width + 10, Object.Height + 10

Object.Hue, Object.Brightness, Object.Contrast, Object.Opacity
also Object.States("name").Hue, Object.States("name").Brightness,
Object.States("name").Contrast, Object.States("name").Opacity)

If you want to dynamically change the color, hue or brightness of an object, it is easy to do with these commands. Simply set a value of 1-255 for hue, -255 – 255 for brightness and -100 – 100 for contrast. Set it to 0 to remove any previously made changes.
You can also set or retrieve the level of opacity that an object has in a range from 0 (totally invisible) to 100 (totally visible).
Examples:

For x = 0 To 255
Object.Hue = x
Next

Object.Brightness = -30

DesktopX.Object("anotherobject").Contrast = 40

Object.Opacity = 60

Object.State, Object.StatePreempt

Through use of Object.State you can change or retrieve the state of an object. This is one of the most common commands used in script as it is used to trigger objects to act certain ways. Object.StatePreempt should be used when you want to set a state immediately without waiting for any animations etc to complete.
Examples:

If Object.State = "Command executed" Then ...

x = DesktopX.Object("anotherobject).State

DesktopX.ScriptObject("scr_object).Object.StatePreempt = "Hide"

Object.Text, Object.TextColor, Object.TextBorder, Object.TextBorderColor
also Object.States("name").Text, Object.States("name").TextColor, Object.States("name").TextBorder, Object.States("name").TextBorderColor

If your object is a text object rather than an image, you can manipulate it using script changing either the text itself or the appearance. You can set/retrieve the text or it's color and well as defining whether the text has a border, and if so what color it is.
The colors are most easily set using an RGB value separated via commas.
Examples:

If Instr(Object.Text, "Data") Then Msgbox "String found"

Object.TextColor = RGB(120,200,255)

Object.TextBorder = True

Object.TextBorderColor = RGB(255,0,0)

Object.SetTimer, Object.KillTimer, Object.Sleep

As discussed earlier, the Object.SetTimer sets an event and an interval to which you can then add code to run at the predefined interval. If you need to stop a timer running you can use KillTimer to stop it. e.g. Object.KillTimer 12345 will stop any code in the Object_OnTimer12345 event from running.
Object.Sleep stops code running temporarily for a defined period of time. For example Object.Sleep 1000 will wait for 1 second before continuing to run.
Example:

Sub Object_OnScriptEnter
  Object.SetTimer 12345, 600000
End Sub

Sub Object_OnTimer12345
  MsgBox "The time is " & Time()
End Sub

Sub Object_OnScriptExit
  Object.KillTimer 12345
End Sub

Object.ExecuteCommand

This executed any command associated with the object in it’s Object Type. This is particularly useful for doing things at set intervals or events, such as when DesktopX exits.
Example:

Sub Object_OnScriptExit
Object.ExecuteCommand
End Sub

Object.LocalStorage, Object.PersistStorage

When coding it is often useful to store persistent information which can be retrieved and used as required across multiple executions of the same object or widget.
To store data you need to give the data a unique reference (for that object) and set it's value. For example Object.LocalStorage("MyZip") = 48152 would place the value 48152 in a storage variable called MyZip. "MyZip"=48152 will be automatically saved and restored when the object is unloaded and reloaded.
The difference between the two types is in its persistence across object packaging and distribution. LocalStorage will NOT be saved when the object is saved as .dxpack or a widget is built. PersistStorage instead will save its value.
LocalStorage is useful to store personal information, like a passwork or a ZIP code. Infact, you don’t want such information to be preserved when you export and redistribute the object to other people. However, you want these values to be preserved across multiple run of the same object/widget.

Example:

Sub Object_OnScriptEnter
  If Object.LocalStorage("MyZip") = "" Then
    Object.LocalStorage("MyZip") = "48152"
  End If
  Object.SetTimer12346, 3600000
End Sub

Sub Object_OnTimer12346
  GetWeather(Object.LocalStorage("MyZip"))
End Sub

Sub Object_OnScriptExit
  Object.KillTimer 12346
End Sub

Function GetWeather(zip)
  ...
End Function

Object.OnTop

The object pushes an object to the top of the z-order which obviously makes it more visible. The below example makes an object appear above other objects when you move the mouse over it.
Example:

Sub Object_OnStateChange(state)
  If state = "Mouse over" Then
    Object.OnTop
  End If
End Sub

Object.SetFocus

The simply sets an objects focus so it can respond to events. For example all objects have an Object_OnSetFocus so this will be triggered if this command is used. Also, where a text based DesktopX object responds to functions based on keyboard or mouse activity (e.g. Function Object_OnChar(dwKeyCode, flag), Function Object_OnLButtonDown(x, y)) then it will respond when these events occur. You can also apply this to ActiveX controls, so for example if an object contains a DesktopX Edit Control then setting its focus will prepare it to accept text input.
Example:

Sub Object_OnStateChange(state)
  If state = "Command executed" Then
    Msgbox "Ready for input"
    Object.SetFocus
  End If
End Sub

Object.TooltipText

This allows you to set the tooltip of the object which is particularly useful to provide additional information to the user. You can also use this to provide different information depending on different circumstances.
Example:

If Object.Text = "New mail" Then
  Object.TooltipText = "Click to launch mail software"
Else
  Object.TooltipText = " "
End If

Object.AppBar

An AppBar is an object that is designed to be attached to the edge of the screen like the Taskbar. Also like the taskbar it can be set to autohide, but beyond this you can undock it as well so it can be moved on the screen. When an appbar is set to Autohide, then moving the mouse over the edge of the screen will cause the AppBar to smoothly appear.
Note that Object.AppBar can only be written, not read, so if you need to check the mode at any time you need to set a variable when you set the mode, and then query the value of this variable. Example 1 shows how you may set a variable in this manner.
The values for Object.AppBar are as follows:
0 = Disabled
1 = Docked
2 - Autohide
Example:

Sub Object_OnScriptEnter
  Object.AppbarMode = 1
  appmode = 1
End Sub

If state = "Command executed" Then
  DesktopX.Object("maindock").AppbarMode = 2
End If

Object.Directory

This tells you the directory within which the object is located. This will point to the user’s theme directory.

Object.Sound *

This allows you to set the sound associated with the object either globally or specific to certain states. The sound file targeted can either be a WAV or MP3 format file.
Example:

Object.Sound = "c:\mydirectory\mytune.mp3"
Object.State("Mouse down").Sound = "ding.wav"

Object.Volume

This allows you to set the volume of the sound played by an object. The range is 0 (muted) to 100 (full system volume)
Example:

Object.Volume = 80
Object.Volume = Object.Volume + 10

Object.Picture
also Object.States("name").Picture

This allows you to get/set the picture of an object or state.
Example:

Object.Picture = “image01.png”
Object.States(“Mouse away”).Picture = “C:\images\image01.png”
Object.Picture = http://www.something.com/pic.png

Notes:
- You can use the following modes:
o File names: DX will check into the current theme or widget folder. Note that files must be registered as custom files or bound to at least one state for them to be packed into a .dxtheme, .dxpack or .exe.
o Full path: this can be useful for totally dynamic things like a Picture viewer widget in that you can simply do:

Sub Object_OnDropFiles(files)
Object.picture = files
End Sub

 Full path images are not exported.
o Remote paths: you can use this to easily make a webcam object.
 Remote path files are not exported.

Object.SetPicture
also Object.States("name").SetPicture

This method let you set the picture of an object or state AND its other properties in one call.
Syntax:

Object.SetPicture fileName, frames, interval, flags
For fileName see Object.Picture.
Frames is the number of frames in the picture.
Interval is the number of milliseconds between each frame.
Flags is a combination of the following flags:
&H00000001 – Loop
&H00000002 – Reverse
&H00000004 – Alternate
&H00000008 – Interruptable
&H00000010 – Static

Object.CurrentFrame

Gets/sets the current frame of the animation. In order to use this, the animation should be set “Scripted” in the Properties panel.

Object.Child

Returns true if the object is a contained child. If it has a parent but it is only “owned” (Child = No in Summary page) , it will return false.
Contained children coordinates are relative to the parent’s top/left corner.

Object.SetMargins
also Object.States("name").SetMargins

This allows you to assign the image margins and tile/stretch settings of a state or all states of an object.
Syntax:
Object.SetMargins leftMargin, topMargin, rightMargin, bottomMargin, boolStretchX, boolStretchY

Values are distance from each edge. Set boolStretchX and boolStretchY to true to configure stretching mode. Leave false for tiling mode.

Object.Command and Object.CommandParams

Gets/sets the object command and parameters for Shortcut and URL object types.

Object.Group

Gets/sets the object group name.

Object.RegisterHotkey and Object.UnregisterHotkey

Let you register an hotkey combination. A special event is called when the user hits the hotkey.
Syntax:
Object.RegisterHotkey hotkeyID, hotkeyValue

hotkeyValue is defined as a long in the same way the HKM_GETHOTKEY returns ( http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/
platform/commctls/hotkey/messages/hkm_gethotkey.asp
):
The virtual key code is in the low-order byte, and the modifier flags are in the high-order byte. The modifier flags can be a combination of the following values:

&H00000001 - shift
&H00000002 - control
&H00000004 - alt
&H00000008 - extended key

Once the hotkey is set, the object script will be notified through:

Sub Object_OnHotkey(id)

where id is the first parameter that is passed to RegisterHotkey.

To unregister the hotkey call:

Object.UnregisterHotkey id

Object.Comments

Gets/sets the object comments field

Object.SetFont
also Object.States("name").SetFont

Let you assign all font settings at once.
Syntax:
Object.SetFont fontName, size, boolBold, boolItalic, boolUnderline, boolStrikeOut, lfCharSet

You can leave the last parameter = 0

Object.FontName, Object.FontSize, Object.FontBold, Object.FontItalic, Object.FontUnderline, Object.FontStrikeout
also Object.States("name").FontName, Object.States("name").FontSize, Object.States("name").FontBold, Object.States("name").FontItalic, Object.States("name").FontUnderline, Object.States("name").FontStrikeout

Let you get/set individual font options.

Object.SetShadow
also Object.States("name").SetShadow

This allows you to assign the shadow options of a state or all states of an object.
Syntax:
Object.SetShadow boolEnabled, sharpness, darkness, offsetX, offsetY, sdwColor

Sharpness ranges from 0 to 100.
Darkness can take values greater than 255.

Object.SetScript(name)

It let change script at runtime. This has a couple of rules:

  • Path can be either relative to local path (CurrentTheme) or full path. Files pointed to relative paths are automatically saved into .dxpack/.desktop/.exe packages.
  • ActiveX dynamic scripting is not yet supported.
  • An object must be first configured as scripted and eventually have a blank script if no real script is initially needed.
  • The default script, edited from DesktopX GUI will not be used, if overridden by an external script, unless the external script is "unlinked" by calling Object.SetScript("").

Object.Cursor

Let you get/set the current cursor.

0 = Normal select
1 = Help select
2 = Working in background
3 = Busy
4 = Precision select
5 = Text select
6 = Handwriting
7 = Unavailable
8 = Vertical resize
9 = Horizontal resize
10 = Diagonal resize 1 (NW-SE)
11 = Diagonal resize 2 (NE-SW)
12 = Move
13 = Alternate select
14 = Hand
 


7/29 

SkinStudio 6.2 Released

7/25 

A God Has Fallen - New Demigod Trailer Released

7/24 

Sins of a Solar Empire v1.1 Beta has Arrived

7/23 

Stardock Releases New WindowBlinds 6.2 Update

7/22 

Stardock Releases The Political Machine v1.04 with New Characters

7/22 

Stardock Releases MyColors 2.5

7/17 

DesktopX 3.5 Officially Released

7/11 

Corel WinDVD 9 and Painter X Now Available on Impulse!