DesktopX Scripting: Learning the basics, Part 1

VBScripting, but its not as hard as you'd think...

Welcome to Part 1 of the basics of DesktopX

by CerebroJD

First thing I want to convey to you about this, is that its NOT HARD to learn. Everything that we cover will be in tiny steps designed to get you working in DesktopX in as little time as possible. I hope I can keep things clear and straightforward. Please, comment once you have read through it and let me know if you need any sort of clarification!


When you first create a new DesktopX object, you are presented with its Properties dialog, from which you can edit all sorts of settings. Actually, everything about the object, including its location, transparency, and shadows. Of course, its not limited to that; Each object is nearly infinitely configurable, with hundreds of extra bits hiding all over the place.

The first thing we're going to do is generate the default script, but before we do that, we're going to give this default object a name. Look under the Summary tab in the Properties dialog for the attribute marked Object ID. For the purposes of this writeup, I'm going to use the name "Test". Once that is done, go to the General tab, look near the Script section, and hit New. A new box should show up:

This box is your generic script editing box for DesktopX. Using just the properties box, you can make pretty objects, but its in here that the true power of DX is unleashed. Using VBScript, you can manipulate not only this object that you are working on, but also other objects. You can perfom mathmatical calculations, make timers, etc. However, we're not gonna start off that complicated... yet. We'll get there though.

As you can see, there is already a default script in the script editor. Currently, it does nothing besides call two empty subs. A sub is a block of code that executes when its told to. Like an automatic function, since it doesnt need explicetly called in the script. The two that are in there by default are very straight forward. The green comments also indicate the purpose of each sub. We'll just make a note of that right now: An apostrophe will make everything that comes after it on that line invisible to the script parser, allowing you to comment your work.

Ok, in the script editor, we're going to begin our work withing the confines of the first sub. This one is designed to run right when you first apply the changes, so we'll see the stuff we put into the code take effect immediately after we apply them. Now to begin coding.

Recall now that the object we are working in is named "Test". We called it that way back at the beginning, remember? In order to get the script talking with that object, we've got to enter in some code, and we're gonna do it right between the top and bottom bits of that first sub:

DesktopX.Object("Test")

Once you have that in, you need to have some kind of attribute on it to modify. We'll do something basic, like width. Easy enough:

DesktopX.Object("Test").Width

Now, finally, the attribute must be set to equal something, and we'll just use something basic:

DesktopX.Object("Test").Width = 300

Ok, so that block of code is going to stretch the width of the object to 300 pixels wide as soon as the script is applied. Check it out by exiting the script editor, then hitting apply. In theory, you should get something just like this:

Final code, start to finish:

'Called when the script is executed
Sub Object_OnScriptEnter
DesktopX.Object("Test").Width = 300
End Sub

'Called when the script is terminated
Sub Object_OnScriptExit

End Sub

More to come soon!
17,683 views 9 replies
Reply #1 Top
Great start! Short, simple, and very understandable. I'd say keep going as you are.
Reply #2 Top
yes, even i can follow this......
Reply #3 Top
Eeeeeexcellent! Thanks for this. I think I could figure out this scripting stuff, I just need someone to walk me through it like this.
Reply #4 Top
Excellent tutorial..

I can manage simple objects but I really need very short step by step instruction..too much info and I get confused. This was a great start ..
Reply #6 Top
Finally a scripting tutorial that goes my speed with my understanding - please keep this up. I have some objects that I want to add scripting to, and I think this is right up my ally.

Thanks - Einy
Reply #7 Top
Good good! darquiel: Since the images are hosted on my site, me moving things around sometimes affects image availability. Also, server downage can prove to be annoying.
Reply #8 Top
very nice tutorial,
it helped me a lot
Reply #9 Top
I agree with Einstein. This is my speed and would love to see more simple tutorials like this. I can follow along and it makes sense to me. Please give us more.