DesktopX Scripting: Learning the basics, Part 1

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

Friday, August 5, 2005 by CerebroJD | Discussion: DesktopX Tutorials

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!
Mnelson
Reply #1 Friday, August 5, 2005 8:57 AM
Great start! Short, simple, and very understandable. I'd say keep going as you are.
-OZZY-
Reply #2 Friday, August 5, 2005 6:18 PM
yes, even i can follow this......
BlueDev
Reply #3 Tuesday, August 9, 2005 9:00 AM
Eeeeeexcellent! Thanks for this. I think I could figure out this scripting stuff, I just need someone to walk me through it like this.
Fairyy~
Reply #4 Tuesday, August 9, 2005 9:11 AM
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 ..
darquiel
Reply #5 Wednesday, October 12, 2005 4:07 PM
I like it.
But it looks like the images are gone?
What happened.
Einstein
Reply #6 Thursday, December 29, 2005 7:13 PM
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
CerebroJD
Reply #7 Friday, December 30, 2005 1:25 AM
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.
sAARGe
Reply #8 Wednesday, November 14, 2007 5:09 PM
very nice tutorial,
it helped me a lot
DandoB
Reply #9 Wednesday, November 14, 2007 8:32 PM
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.

Please login to comment and/or vote for this skin.

Welcome Guest! Please take the time to register with us.
There are many great features available to you once you register, including:

  • Richer content, access to many features that are disabled for guests like commenting on the forums and downloading skins.
  • Access to a great community, with a massive database of many, many areas of interest.
  • Access to contests & subscription offers like exclusive emails.
  • It's simple, and FREE!



web-wc01