
3.2 Preview Guide
Our story so far...
DesktopX was the first program (for PC or Mac) that enabled end-users to easily create desktop objects that could be combined together to form mini-programs commonly referred to as widgets (or gadgets) or used to design an entire desktop environment.
Over the past few years, widgets and gadgets have become very popular with Microsoft, Yahoo, Google, and others all getting into the act. In power, no other platform can deliver what DesktopX can do. With that power, however, comes complexity. Stardock has continued to focus on ways to make it easier for developers and artists to fully harness the power of DesktopX.
Another important event is the coming of Microsoft gadgets. Microsoft's gadget concept is very similar to what DesktopX can do. Stardock's long-term goal is to enable users to export their DesktopX creations as Microsoft gadgets. The powerful development tools and underlying DesktopX technology (called DirectGUI) will be able to be used to create Windows sidebar gadgets and more.
The first step in that path is DesktopX 3.2 which has two main new features:
- Windows Vista compatibility. Content made with DesktopX 3.2 will work on Windows Vista.
- Scripts can now be externally located making it much easier for content makers to create their own library of scripts.
A new development environment
Most end users won't really notice the difference between 3.1 and 3.2. What they will notice is an increased variety in the types of scripts and hopefully, more content from desktop, gadget, and widget creators since the process of creating "Stuff" is streamlined.
For this example, I am going to make a dictionary widget. Please note I am not an artist. I'm a software developer so the graphics in this will be painful.
Example: Dictionary widget
One of the advantages DesktopX has over other "widget" enablers is that it provides a GUI for most of the common, tedious work. You don't, for instance, have to (though you can if you want) define images and objects using some text editor. In DesktopX, it's all GUI driven. Try to create a dictionary widget as easily in any other platform.
Step #1: Background window

From the DesktopX Helper toolbox, I press "Create object". Then I go to its properties and press the change appearance button which opens a dialog asking me to provide the image. I provide the image.
Step #2: Provide the text input box

The user has to have something to type their word they're looking up into. So I go through the same object creation procedure as before except for this:
I press "New" on script which opens up the script editor box. Then I choose ActiveX control. Then I choose DesktopX edit control. (I agree, we should have really common controls not require the user to go through this but this also exposes users to all the possibilities -- your computer is full of objects already. DesktopX lets you make use of them easily on your desktop).
Then just exit the dialog. Now, HOLD DOWN THE CONTROL KEY when you click on that object and you can resize it.
Step #3: Create the text output area
Now we need the area to output the definition. So go through the same object creation method as before (you can also create a new object from the DesktopX system tray item). One change though:
On the "States" page change the appearance from Image to Text.

Now, you can get pretty smug because you can visually change all the text settings from this GUI rather than mucking with it in some ASCII text editor. Get it the color and size you want first. And thinking ahead here, you will want to make sure it word wraps. So go to the summary page and set its width in pixels. I'm going to set it to 400.

Anyone who's made widgets or gadgets knows how annoying it can be to do this in script. By contrast, the total time taken so far is about 30 seconds to create this widget (other than making the tutorial). Did I mention our goal for Windows Vista is to allow creations to go onto the Windows Sidebar?
Step #4: Write the script
This is where we part ways with really casual users. If you're not a developer, this part may be confusing.
The first thing we need to do is give these objects some names so that they can talk to each other. On the summary page is the ObjectID. Name your objects something you can remember (like Dictionary_Text) on the object we just created.
I'm going to write two scripts. The first script is a tiny one that I'll attach to the edit field.
Here's my script:
Sub Control_OnKeyPress(AsciiValue)
If AsciiValue = 13 Then
DesktopX.ScriptObject("Dictionary_Text").LookItUp
End If
End Sub
All I'm doing is looking for Ascii value 13 (which is the enter key basically) to be pressed and then I'm going to call "LookItUp" in my text object which will grab the contents and send it to dictionary.com. I am going to name the entry field object "Dictionary_EntryField" so that I can refer to it.
The second script is more complicated and here is where DesktopX 3.2 starts to shine -- dynamic scripts. I'm going to write the script in Visual Studio. Special thanks to Sranshaft who made a dictionary object that I could use as the basis of this.

The one annoying thing I ran into that we're trying to think of a more convenient solution is that when you change your script in Visual Studio, you have to go to the object that is using it, right click on it, and toggle "script enable" back and forth in order for it to update what's there. If anyone has any preferences on how we essentially "reload" the script to be "recompiled" on the fly, let us know.
Anyway, so I took Sranshaft's dictionary script and modified it. It's not very long. In fact, most of it is just replacing the junk in the response with blank characters (i.e. getting rid of the HTML characters).
Step #5: Connect the script to the object.
Now I need to go back to my text object and connect the script:

I wrote my script over in my "c:\projects\dxdev\scripts\dictionaryscript.vbs".
So why do it this way? Why have your scripts be external to the object? In DesktopX 3.1, you couldn't. The idea was to have scripts be totally integrated into the object. The problem with that is re-usability. It's a lot easier for developers to have a library of scripts that they make that they can then just refer to. Over time, depending on feedback and interest, we can make this even easier to do. The other reason to do this is to prevent catastrophic loss. For instance, while I was modifying this script and testing the output, I got a huge overflow that brought down DesktopX. No problem, I just restarted DesktopX and it remembered my last state. But there's a dialog that pops up asking if you want to erase everything (in the event you get yourself into an endless loop or something). If I had answered that incorrectly, I would have lost my work. But with external scripts, I don't lose all my work, the scripts are still there on my hard drive, easy to find.
External scripts also benefit for users who use real-time data protection programs like KeepSafe which will create revisions of your creations so that if you really screw something up, you can go back to a previous version (and if you don't have KeepSafe already installed, quit reading this and go get it RIGHT NOW).
Step #6: Clean up and finish
Now it's just a matter of taking the 3 objects I created and putting them together.
This just means dragging the 3 objects around on screen until you've positioned them the way you want and then grouping them. Don't forget to hold the CTRL key down when you are moving the ActiveX control.

I just drag select the objects, right click and choose "group".
And then voila.

Step 7: Export it to a widget.
DesktopX 3.2 widgets are .EXEs. So as long as you have DesktopX installed, you can use them like any EXE. Using Keyboard LaunchPad I then assign them a hot key so that when I need something like currency conversion or dictionary lookup or whatever, I just hit a hot key to bring it up.
To export as a widget just select all the objects, right click, and choose Export as widget which will take the user through the steps of assigning it an icon and the file name.

And voila.
We're still working out some of the kinks such as how to handle external scripts when it comes time to package them. Do we allow users who import widgets that use external scripts to see them? Could this be used as a way for people to protect their code? Hence, why DesktopX 3.2 is still in beta. But you can see where we're going.
DesktopX 3.2 is in beta. If you have Object Desktop, DesktopX is one of the programs that comes with it (along with WindowBlinds, IconPackager, Keyboard LaunchPad, etc.).