First Previous Page 1 of 2 Next Last

Learning DX Step-By-Step - #11

Animation Station

Wednesday, June 6, 2007 by RomanDA | Discussion: DesktopX Tutorials

Step-by-Step Tutorials

#11 - Animation

A series by RomanDA

Listing of other DX Tutorials: Click here
Today's Lesson: "Animation"

Ok, So.. I lied.  Well I didn't Lie, I really was done, but this one was really simple and I saw some people asking about this, and I had just finished making just this thing.  I figured why not.
So call it a bonus for me becoming a Master.. or call it, I was bored.

We will be Using the SCRIPTED Animation check you have seen in the Object "Animation" tab.

For this and all the Step-By-Step DX Tutorials you will need to purchase DesktopX for $14.95 from Stardock.

Lets get started.

STEP 1 - Create the objects


We are going to make a single object here, but its more complicated then normal.

First thing you have to do is make a PNG that has multiple images inside it.  There are a LOT of ways to make this kind of PNG.

I have used FLASH to export a series of images, then they all need to be complied into one image.
Like this:

The trick with the frames (objects) in this kind of image is that the need to be EXACTLY The same size, and they have to be spaced EXACTLY the same as well.
In this case the image has 4 frames, I numbered them for you so you will be able to see the animation in action.

Create a NEW object, call it "TEST" or whatever. 
You can (save-as) the above image, and use it for testing.  The Catch here is make sure you change the ANIMATION TAB in the STATES tab of the properties to show:

(4) Frames, and SCRIPTED is checked.

STEP 2 - Moving Ahead - Add a Script


Create a SCRIPT on the object we just created.

ANIMATION Code
  Function Object_OnLButtonUp(x, y, Dragged)
  If Dragged = False Then
    CurFrame = object.CurrentFrame + 1
    If CurFrame < 4 Then
      object.CurrentFrame = CurFrame
    Else
      object.CurrentFrame = 0
    End If
  End If
End Function

Lets look at the above script.
First we use the same function we use all the time to handle click:

ANIMATION Code
  Function Object_OnLButtonUp(x, y, Dragged)
  If Dragged = False Then

Here is the main part of the script.  The script looks at the object to see what its Current Frame is.
CurFrame = object.CurrentFrame + 1
This is based on 0-3 not 1-4, even though there are 4 frames in the animation.  We START at 0 not 1!!!!

Then we check to see if CurFrame its less than < the max number of frames (4 frames of animation).
If so, then we make the current frame the new CurFrame.

Or else the object's CurrentFrame is set to 0 (the first frame of the animation).

ANIMATION Code
      CurFrame = object.CurrentFrame + 1
    If CurFrame < 4 Then
      object.CurrentFrame = CurFrame
    Else
      object.CurrentFrame = 0
    End If

CONCLUSION


So, that's about it.  you click on the object, and it changes the current frame up 1 each time till it gets to the last frame, then it goes back to 0.
I used this in something I'm working on right now.

I hope you took the time to enter the code (not just copy/pasted the entire thing) so you could work thru the tutorial step-by-step and see how things work. 

This one was very simple, but I know I didn't know how to use this till I had to, so I hope it helps everyone out.

This REALLY will be my last tutorial for a while.  I hope you have enjoyed this step into DX.

Enjoy,
RomanDA
AKA: David A. Roman
http://romanda.wincustomize.com

Learning DX Step-By-Step - #10

Hide & Seek

Thursday, May 31, 2007 by RomanDA | Discussion: DesktopX Tutorials

Step-by-Step Tutorials

#10 - Hide & Seek

A series by RomanDA

Listing of other DX Tutorials: Click here
Today's Lesson: "Hide & Seek"

This will be the last in this series of Tutorials. I hope you have enjoyed them, and managed to get something out of them.
In this lesson we will do some basic DX operations on one object from another.
We will cover the following:

  • HIDE/SHOW one object by clicking on another
  • SLIDE/HIDE one object by clicking on another
  • EXPAND/SHRINK one object by clicking on another

For this and all the Step-By-Step DX Tutorials you will need to purchase DesktopX for $14.95 from Stardock.

Lets get started.

STEP 1 - Create the objects


For this tutorial we will be using 3 objects: (right click and SAVE the images to your pc)

Mask
Button
Target
  • Create 3 objects. (look at the old tutorials for info on how to do this)
  • Create an object called Mask
    • width: 260
    • height: 90
    • Group Tutorial10
    • Widget Tutorial10
    • NOTE: we will later change the transparency to 0, but for now we want to see how the mask makes things work.
  • Create an object called Target
    • Make its PARENT object MASK
    • place it at 0,0 for top/left.
    • Group Tutorial10
    • Widget Tutorial10
  • Create an object called Button
    • place it above the TARGET/MASK object (like you see in the table above, just above it)
    • Widget Tutorial10
    • NO GROUP!!!!
  • We will make a VERY simple script on Button to hide/show Target.

STEP 2 - Add a simple HIDE/SHOW Script


Add the following script to Button:

BUTTON Code
  Function Object_OnLButtonUp(x, y, Dragged)
  If Dragged = False Then
    If desktopx.Object("Target").visible = True Then
      desktopx.Object("Target").visible = False
    Else
      desktopx.Object("Target").visible = True
    End If
  End If
End Function

Lets look at the above script.
Its VERY simple, we look at the Visibility of Target and see if its True (is it visible), if so, we HIDE it (False), if its Hidden (False) we Show it (True).

BUTTON Code
  If desktopx.Object("Target").visible = True Then 'is Target Visible?
  desktopx.Object("Target").visible = False 'If so, HIDE it
Else
  desktopx.Object("Target").visible = True  'If not, SHOW it
End If

That's all there is to it. 
SAVE the code.
Click Button to see how it toggles Target on/off.
The MASK will stay there, but that's ok for now, we will play with that NEXT.

Here is what you will see:

Normal View CLICKED

STEP 3 - Sliding Target


Now, lets change things up.  Lets make the TARGET SLIDE up into the menu.  We do this by making a script that has a few Timers (in order to slow up the sliding).
The script is a modified version of my script I used in another tutorial.  The basics are this.
  • The Function Object_OnLButtonUp(x, y, Dragged) is the button being pressed (well released)
    Inside here we look at the TOP position of the TARGET.
    If the TARGET's top is = 0 this means its being shown and is at the normal position, so we want to HIDE it (Timer 200).
    If not then we want to SHOW it (Timer 100).
    We kill the timer just to be sure, then we set the correct timer to start.
  • In the timers we simply look to see if the top is at 0 or at -90 (shown / hidden).
    All we do to HIDE the TARGET is to move it 5 spaces at a time UP
  • Because we have the TARGET's parent as a MASK it will move up past the Visible area the mask shows, so it will look like its vanishing.
  • In the Timer we keep moving it UP until it reaches -90 (the object it 88 pixels tall), then we kill the timer.
  • When we click the button again it sees the TARGET.top position is -90 and it SHOWS it by doing the opposite as it does to SHOW it.
  • We move it DOWN 5 pixels at a time till its back to 0, with the mask setup it looks like its sliding from nowhere.
  • We are using this
    Sub Object_OnScriptEnter
      desktopx.Object("Target").top = 0
    End Sub
    To set the initial TARGET position to 0, just so that it shows the menu on startup.  If you wanted to have the menu HIDDEN on startup, you would change the 0 to -90

Here is the script to SLIDE the TARGET UP/DOWN: (this code goes in the BUTTON)
REPLACE the code from the "HIDE/SHOW" above. 

BUTTON Code
  Sub Object_OnScriptEnter
  desktopx.Object("Target").top = 0
End Sub

Function Object_OnLButtonUp(x, y, Dragged)
  If Dragged = False Then
    If desktopx.Object("Target").top = 0 Then
      object.KillTimer 100
      object.SetTimer 200,10
    Else
      object.KillTimer 200
      object.SetTimer 100,10
    End If
  End If
End Function

Sub object_ontimer100
  If desktopx.Object("Target").top < 0 Then
    desktopx.Object("Target").top = desktopx.Object("Target").top + 5
  Else
    object.KillTimer 100
  End If
End Sub

Sub object_ontimer200
  If desktopx.Object("Target").top > -90 Then
    desktopx.Object("Target").top = desktopx.Object("Target").top - 5
  Else
    object.KillTimer 200
  End If
End Sub

This would end up looking like this (when you click the button it goes UP then DOWN):

To make this look a LOT better you could go in and make the MASK's transparency = 0 so that its basically invisible.
You can use whatever objects you want, you would only have to change the -90 to the correct height for the object you want to use.
Again, these are just samples for you to work with.

STEP 3 - Shrinking / Expanding


Ok, so we know how to HIDE/SHOW by clicking the button, and we can make it SLIDE UP and DOWN too.  Now lets make the TARGET EXPAND / SHRINK.
To do this we will use some of the same functions as above.  Only now we want to not MOVE the TOP, we want to change the WIDTH of the TARGET.
The targets "default" size is: 255x88  What we want it to do is shrink down to 30x88 (so that it EXPANDS out from the left to the right).

One of the things we need to do is change the ADVANCED settings on the TARGET image.
Click on properties, then States then ADVANCED:

This will make it so the 3d EDGE of the TARGET stays the right width, and the insides kind of Expand.

 

BUTTON Code
  Sub Object_OnScriptEnter
  desktopx.Object("Target").top = 0
  desktopx.Object("Target").width = 25
End Sub

Function Object_OnLButtonUp(x, y, Dragged)
  If Dragged = False Then
    If desktopx.Object("Target").width = 25 Then
      object.KillTimer 100
      object.SetTimer 200,10
    Else
      object.KillTimer 200
      object.SetTimer 100,10
    End If
  End If
End Function

Sub object_ontimer100
  If desktopx.Object("Target").width > 25 Then
    desktopx.Object("Target").width = desktopx.Object("Target").width - 5
  Else
    object.KillTimer 100
  End If
End Sub

Sub object_ontimer200
  If desktopx.Object("Target").width < 255 Then
    desktopx.Object("Target").width = desktopx.Object("Target").width + 5
  Else
    object.KillTimer 200
  End If
End Sub

This would end up looking like this (when you click the button it EXPANDS / SHRINKS):
It wont look exactly like this, the edges should stay and the middle should shrink (I just dumped this into flash, so its not the same).

In the case of the EXPAND/SHRINK, you do NOT need the MASK, so you could delete that object.  I left it here only for reference.

CONCLUSION


I hope you took the time to enter the code (not just copy/pasted the entire thing) so you could work thru the tutorial step-by-step and see how things work. 

This tutorial is actually 3 in 1.  But they are related, so I wanted to make this last Tutorial a good one.

This will be my last tutorial for a while.  I hope you have enjoyed this step into DX.

Enjoy,
RomanDA
AKA: David A. Roman
http://romanda.wincustomize.com

Learning DX Step-By-Step - #9

Wallpaper Changer

Wednesday, May 2, 2007 by RomanDA | Discussion: DesktopX Tutorials

Step-by-Step Tutorials

#9 - Wallpaper Changer

A series by RomanDA

Listing of other DX Tutorials: Click here
Today's Lesson: "Wallpaper Changer"

In this lesson we will walk thru a few built-in commands in DX that allow you to create a Wallpaper Changer.
We will start simple and add to the script.  It is amazing all the things that are built into DX.

We will use the file dialog box, the wallpaper changer, create a "right-click" menu and even a custom preference window.

For this and all the Step-By-Step DX Tutorials you will need to purchase DesktopX for $14.95 from Stardock.

Lets get started.

STEP 1 - Using the System.FileOpenDialog & System.SetWallpaper


Create a new object (look at the old tutorials for info on how to do this).

Once it is created (you can use any image you want, but for me I'm just going to use the standard round DX image.

Add the following script:

Vbscript  Code
  Function Object_OnLButtonUp(x, y, Dragged)
  If Dragged = False Then
    '--- Change the line below to pick the folder
    '--- where you keep your wallpapers -----
    FolderName = "C:\wallpapers"
    wallpaper = System.FileOpenDialog("Select Wallpaper...", "", FolderName , "Wallpapers|*.jpg", 0)
    System.SetWallpaper wallpaper, 3
  End If
End Function

Looking at the above script we have some new things in here.

Vbscript  Code
  System.FileOpenDialog("Select Wallpaper...", "", FolderName , "Wallpapers|*.jpg", 0)

The FileOpenDialog is a built-in DesktopX function.  It allows you to select a file from a standard windows looking open dialog box.
The format is very simple. 

The way this works, is you click on the object, it pops open the FileOpenDialog , then you select your wallpaper this file name gets saved into the Wallpaper var.

Vbscript  Code
  System.SetWallpaper wallpaper, 3

This is another built-in DesktopX command.  It does exactly what it says "SetWallpaper".  It gets passed 2 items:

  • wallpaper - the file we picked from above, has to have the entire path (IE: c:\wallpaper\mywallpaper.jpg )
  • 3 - There are 3 options for this: (we will add a right-click menu later to select this)
    • 0 = use default wallpaper
    • 1 = Center wallpaper
    • 2 = Tile wallpaper
    • 3 = Stretch wallpaper

So with just the above script you have created a object/widget that allows you to click, pick a file, and have it set the wallpaper to that file.

This is good, but every time it loads it points to that same folder, what if you had multiple folders?  What if you want it to STORE what folder you picked the last time?

STEP 2 - Pulling the Folder name from the Open Window Dialog box


Lets add a few lines of code to our script.

Our entire script looks like this now:

Vbscript  Code
  'Called when the script is executed
Sub Object_OnScriptEnter

End Sub

'Called when the script is terminated
Sub Object_OnScriptExit

End Sub

Function Object_OnLButtonUp(x, y, Dragged)
  If Dragged = False Then
    FolderName = "C:\wallpaper\"
    wallpaper = System.FileOpenDialog("Select Wallpaper...", "", FolderName , "Wallpapers|*.jpg", 0)
    System.SetWallpaper wallpaper, 3
  End If
End Function

By Adding dim FolderName at the very top of the script it will make that variable Global, meaning it will be able to read/write to that var from any/all functions/subs.
If you don't add this it will not be able to pull the value of FolderName from the other functions.

Vbscript  Code
  Dim foldername

'Called when the script is executed
Sub Object_OnScriptEnter

End Sub

'Called when the script is terminated
Sub Object_OnScriptExit

End Sub

We are going to add a way to pull the Folder name from the one we selected in our Dialog box.
To do this we need to "pull" the file name, and then strip that out from the var.

We are going to assume that the user clicked on another drive/folder/filename from the open dialog.
Let's say I picked:  D:\My data\Wallpapers\ZubazisUgly.jpg

Breaking this apart:

  • Set filesys = CreateObject("Scripting.FileSystemObject")
    Sets the var FILESYS to a FileSystemObject
  • f = filesys.GetBaseName(wallpaper)
    Pulls the File name from the entire path
    In this case it pulls: ZubazisUgly.jpg
  • t = instr(1,wallpaper,f)
    This finds the position of the file name in the path, so that we can strip it out.
  • FolderName = left(wallpaper,t-1)
    This pulls the LEFT T-1 characters from the string so we end up with just the path:
    D:\My data\Wallpapers\
Vbscript  Code
  Function Object_OnLButtonUp(x, y, Dragged)
  Dim filesys
  If Dragged = False Then
    FolderName = "C:\wallpaper\"
    wallpaper = System.FileOpenDialog("Select Wallpaper...", "", FolderName , "Wallpapers|*.jpg", 0)
    System.SetWallpaper wallpaper, 3
    Set filesys = CreateObject("Scripting.FileSystemObject")
    f = filesys.GetBaseName(wallpaper)
    t = instr(1,wallpaper,f)
    FolderName = left(wallpaper,t-1)
  End If
End Function

This is all well and good, but the next time we click the button it will still use the C:\wallpaper folder, so we want to add a little more code to save and restore this var.

STEP 3 - Adding the Save / Load registry functions


We are going to add (2) new functions to the script:

  • The SaveSettings and LoadSettings are functions we talked about in Tutorial #6.
  • We are storing the FolderName into the reg key "HKCU\SOFTWARE\desktopx\wallpaperpicker\folder"
  • We use a DEFAULT of the Current DesktopX Executable Directory so that it loads up using the folder the EXE was run from.
    You don't want to hard-code a folder here because not everyone's pc will have that folder location.
Vbscript  Code
  Function SaveSettings()
  Set Sh = CreateObject("WScript.Shell")
  Sh.RegWrite "HKCU\SOFTWARE\desktopx\wallpaperpicker\folder", foldername
  Set Sh = Nothing
End Function

Function LoadSettings()
  foldername = Desktopx.ExecutableDirectory
  On Error Resume Next
  Set Sh = CreateObject("WScript.Shell")
  FolderName = Sh.RegRead("HKCU\SOFTWARE\desktopx\wallpaperpicker\folder")
  Set Sh = Nothing
  Err.Clear
End Function

STEP 4 - Putting it all together


Lets see what the entire script looks like now, with all the above included.

Vbscript  Code
  Dim foldername

'Called when the script is executed
Sub Object_OnScriptEnter

End Sub

'Called when the script is terminated
Sub Object_OnScriptExit

End Sub

Function Object_OnLButtonUp(x, y, Dragged)
  Dim filesys
  If Dragged = False Then
    Call LoadSettings()
    wallpaper = System.FileOpenDialog("Select Wallpaper...", "", FolderName , "Wallpapers|*.jpg", 0)
    System.SetWallpaper wallpaper, 3
    Set filesys = CreateObject("Scripting.FileSystemObject")
    f = filesys.GetBaseName(wallpaper)
    t = instr(1,wallpaper,f)
    foldername = left(wallpaper,t-1)
    Call SaveSettings()
  End If
End Function

Function SaveSettings()
  Set Sh = CreateObject("WScript.Shell")
  Sh.RegWrite "HKCU\SOFTWARE\desktopx\wallpaperpicker\folder", foldername
  Set Sh = Nothing
End Function

Function LoadSettings()
  foldername = Desktopx.ExecutableDirectory
  On Error Resume Next
  Set Sh = CreateObject("WScript.Shell")
  FolderName = Sh.RegRead("HKCU\SOFTWARE\desktopx\wallpaperpicker\folder")
  Set Sh = Nothing
  Err.Clear
End Function

This should allow you to click and open a dialog box, allowing you to pick a folder/file to set the wallpaper, then it sets the wallpaper, and stores the selected folder.

STEP 5 - Adding a Right-Click menu for options.


The next step is to add a menu so we can pick from default/centered/tiled/stretched for the wallpaper.
I made a tutorial a while back on how to add a Right-click menu - CLICK HERE to view that, I'm not going to go thru this step by step, I'm just going to give you the working code.  If you want a break down of how the menu works, please use the above link to the other Tutorial.

The code below will popup a menu when you right-click.  It gives you 4 options, from changing to the default wallpaper, to making it tiled/stretched.
It will do this immediately so you can see what it does, it also stores the info in a Var (WPFormat) so that the next time you pick a wallpaper it will use this same setting.  With 1 exception the 0.  This is designed to set the wallpaper to the default, so we don't want to STORE that, we will default it back to 3 (stretched). 

Vbscript  Code
  Function Object_OnRButtonUpEx(obj,x,y,dragged)
  If Not dragged Then
    Object_OnRButtonUpEx = True
    Set mainmenu = nothing
    Set mainmenu = DesktopX.CreatePopupMenu
    mainmenu.AppendMenu 0, 0, "Default Wallpaper"
    mainmenu.AppendMenu 0, 1, "Center Wallpaper"
    mainmenu.AppendMenu 0, 2, "Tile Wallpaper"
    mainmenu.AppendMenu 0, 3, "Stretch Wallpaper"
    result = mainmenu.TrackPopupMenu(0, System.CursorX, System.CursorY)
    Select Case result
      Case 0
        WPFormat = 3
        System.SetWallpaper "", 0
      Case 1
        WPFormat = 1
        System.SetWallpaper wallpaper, WPFormat
      Case 2
        WPFormat = 2
        System.SetWallpaper wallpaper, WPFormat
      Case 3
        WPFormat = 3
        System.SetWallpaper wallpaper, WPFormat
    End Select
    Set mainmenu = nothing
  End If
End Function

STEP 6 - Putting it all together


We are going to add a few more DIMs at the top:

  • Dim Wallpaper - stores the selected Wallpaper name
  • Dim WPFormat - Stores the Current Wallpaper "format" - stretched/centered/etc.

Here is the FULL script, if you just want to copy/paste this into your object, its your call.

Vbscript  Code
  Dim foldername
Dim Wallpaper
Dim WPFormat

'Called when the script is executed
Sub Object_OnScriptEnter
  Call LoadSettings()
End Sub

'Called when the script is terminated
Sub Object_OnScriptExit
  Call SaveSettings()
End Sub

Function Object_OnLButtonUp(x, y, Dragged)
  Dim filesys
  If Dragged = False Then
    Call LoadSettings()
    wallpaper = System.FileOpenDialog("Select Wallpaper...", "", FolderName , "Wallpapers|*.jpg", 0)
    If len(wallpaper) > 2 Then
      System.SetWallpaper wallpaper, WPFormat
      Set filesys = CreateObject("Scripting.FileSystemObject")
      f = filesys.GetBaseName(wallpaper)
      t = instr(1,wallpaper,f)
      foldername = left(wallpaper,t-1)
      Call SaveSettings()
    End If
  End If
End Function

Function SaveSettings()
  Set Sh = CreateObject("WScript.Shell")
  Sh.RegWrite "HKCU\SOFTWARE\desktopx\wallpaperpicker\folder", foldername
  Sh.RegWrite "HKCU\SOFTWARE\desktopx\wallpaperpicker\WPFormat", WPFormat
  Set Sh = Nothing
End Function

Function LoadSettings()
  foldername = Desktopx.ExecutableDirectory
  WPFormat= 3 'use stretch for default (change to whatever you want)
  On Error Resume Next
  Set Sh = CreateObject("WScript.Shell")
  FolderName = Sh.RegRead("HKCU\SOFTWARE\desktopx\wallpaperpicker\folder")
  WPFormat = Sh.RegRead("HKCU\SOFTWARE\desktopx\wallpaperpicker\WPFormat")
  Wallpaper = Sh.RegRead("HKEY_CURRENT_USER\Control Panel\Desktop\Wallpaper")
  Set Sh = Nothing
  Err.Clear
End Function

Function Object_OnRButtonUpEx(obj,x,y,dragged)
  If Not dragged Then
    Object_OnRButtonUpEx = True
    Set mainmenu = nothing
    Set mainmenu = DesktopX.CreatePopupMenu
    mainmenu.AppendMenu 0, 0, "Default Wallpaper"
    mainmenu.AppendMenu 0, 1, "Center Wallpaper"
    mainmenu.AppendMenu 0, 2, "Tile Wallpaper"
    mainmenu.AppendMenu 0, 3, "Stretch Wallpaper"
    result = mainmenu.TrackPopupMenu(0, System.CursorX, System.CursorY)
    Select Case result
    Case 0
      WPFormat = 0
      System.SetWallpaper "", WPFormat
    Case 1
      WPFormat = 1
      System.SetWallpaper wallpaper, WPFormat   
    Case 2
      WPFormat = 2
      System.SetWallpaper wallpaper, WPFormat   
    Case 3
      WPFormat = 3
      System.SetWallpaper wallpaper, WPFormat   
    End Select
    Set mainmenu = nothing
  End If
End Function

CONCLUSION


I hope you took the time to enter the code (not just copy/pasted the entire thing) so you could work thru the tutorial step-by-step and see how things work.  You will notice I added a small IF under the Open Dialog box so that it only does anything if you select a file, it will crash out without that code if you don't select a file.

I hope you have enjoyed this step into DX, and look forward to the next installment..

Enjoy,
RomanDA
AKA: David A. Roman
http://romanda.wincustomize.com

Learning DX Step-By-Step - #8

Tool-Tip Replacement

Monday, April 30, 2007 by RomanDA | Discussion: DesktopX Tutorials

Step-by-Step Tutorials

#8 - Tool-Tip Replacement

A series by RomanDA

Listing of other DX Tutorials: Click here
Today's Lesson: "Tool-Tip Replacement"

In this lesson we will make a replacement for the built in Tool-tip, one that can be made any color, shadow, transparency, and have it re-size automatically.

This is not going to be a simple STEP-BY-STEP, I'm assuming if you are this advanced into DX, I don't need to explain how to get the script windows up, or edit properties!  This is more like a SCRIPT example, not a step-by-step.

For this and all the Step-By-Step DX Tutorials you will need to purchase DesktopX for $14.95 from Stardock.

Lets get started.

STEP 1 - Create a simple graphic bg to use.

I made a very simple rounded corner background item to use for the tool-tip background.

  • The reason for the RED is because that's the best color to use for changing hue's
  • Rounded corners (just cause)
  • black frame cause I liked it.
  • You can make yours anyway you want.

STEP 2 - Create the ToolTipBack


Create a new object (see previous tutorials).
  • Select the tool-tip-back.png from above.
  • You will need to set the "ADVANCED" properties on the object so it can be re-sized easily.
  • Click on the "summary" tab and name this object "ToolTip_Back"
  • Make this part of the GROUP "ToolTip"

 

STEP 3 - Add the ToolTip_Text to the ToolTip_Back


Create a TEXT object, place it inside the ToolTip_Back object, position might change, on mine its 6/8.
  • Make the text about 10px Arial black, or whatever color you want.
  • Call it ToolTip_Text
  • Make the Parent/Owner  ToolTip_Back
  • make the Group ToolTip
  • for this example change the left/top to 5 & 5

STEP 4 - Making a test object for the tip.


The idea of this tutorial is to have a new-look tool-tip that would replace the built-in one.  So, we need something to mouse over to see this tool-tip.

We need to make something, anything to mouse over.  You can use the "default" object since we dont really care what it looks like.

  • Make a NEW OBJECT, call it TEST_OBJECT.
  • use any image you want, or just the built-in default image.
    (this is what I will show here)
  • We need to add a script to this object.
Vbscript  Code
  Sub Object_OnMouseEnter
  Call ShowToolTip("This is my Tool-Tip")
End Sub

Sub Object_OnMouseLeave
Call HideToolTip()
End Sub

STEP 5 - Adding the code for the Tool-tip

Add the following code to the above TEST object.  Put it at the bottom of the code, under the OnMouseLeave sub section.

I will try and explain some of the code below. (look for the yellow info)

Vbscript  Code
  Function ShowToolTip(TextToShow)
  desktopx.Object("ToolTip_Text").text = TextToShow 'The Text you passed to the function

'--- Set the height/width of the ToolTip_Back object (the +10 +20 are used to give the text box some padding around the text.
  desktopx.Object("ToolTip_Back").height = desktopx.Object("ToolTip_Text").height + 10
  desktopx.Object("ToolTip_Back").width = desktopx.Object("ToolTip_Text").width + 20

'--- We need to position the tool-tip above the object you are mouseing over.
'--- Its a little complicated, but basically we get the width of the object, and the width of the
'--  tooltip_back and center the tooltip_back over the object.

  ttw = desktopx.Object("ToolTip_Back").width/ 2
  ow = object.Width / 2
  temp = ttw - ow
  desktopx.Object("ToolTip_Back").left = object.Left - temp
  desktopx.Object("ToolTip_Back").Top = object.Top - desktopx.Object("ToolTip_Back").height - 10

'--  We have to add a few "IFs here" to see if the object you are mouseing over is at the top of the screen, or of its to close to the left or right side of the screen.
'--  We move the tooltip_back over, down based on the position of the object.

  If desktopx.Object("ToolTip_Back").Top < 20 Then
    desktopx.Object("ToolTip_Back").Top = object.Height + 20
  End If
  If desktopx.Object("ToolTip_Back").left < 20 Then desktopx.Object("ToolTip_Back").left = 10
  If desktopx.Object("ToolTip_Back").left + desktopx.Object("ToolTip_Back").width > system.ScreenWidth Then desktopx.Object("ToolTip_Back").left = system.ScreenWidth - desktopx.Object("ToolTip_Back").width - 30

'--  I have some issues here with these.  I have struggled trying to get the tool tip to show
'-- ON TOP of things on the screen.  It should work with these 3 below.

  desktopx.Object("ToolTip_Back").OnTop
  desktopx.Object("ToolTip_Back").SetFocus
  desktopx.Object("ToolTip_Back").visible = True
End Function

'--  VERY simple function here, HIDE the tooltip_back!
Function HideToolTip()
desktopx.Object("ToolTip_Back").visible = False
End Function

STEP 6 - Test it out.


Once you put the above code into the test object you should be able to mouse over and away and see the tool tip text pop-up.  You might have to make some changes to the above code.

You can move the tooltip_back up or down more based on your preferences.
The changes would be on the places where it shows "Desktopx.Object("ToolTip_Back").Top = ...
You can make that + or - smaller or larger to suit your desires.

STEP 7 - Changes and more changes.


Things you can easily change.
  • Color of the tool-tip background image (play with the hue/brightness/contrast to get it looking the color you would like.
    You could also CODE this so that important tool-tips show up in RED, info in Yellow, etc. Its up to you.
  • Transparency: make the background image as clear as you like.  Again, this could be coded easily.
  • Text: using the  Call desktopx.ScriptObject("ToolTip_Back").ShowToolTip("This is my Tool-Tip")  you can change the text in the tool-tip easily here you can even add multiple lines.
    EX: Call desktopx.ScriptObject("ToolTip_Back").ShowToolTip("Tool Tip Text Line 1" & vbnewline & "second line here" & third line here")
CONCLUSION

This is just my idea on how to change out the built-in tool tip command.

I hope you have enjoyed this step into DX, and look forward to the next installment..

Enjoy,
RomanDA
AKA: David A. Roman
http://romanda.wincustomize.com

Learning DX Step-By-Step - #6

User Input / Save / Retrieve

Wednesday, April 11, 2007 by RomanDA | Discussion: DesktopX Tutorials

Step-by-Step Tutorial

#6 - User Input / Save / Retrieve

A series by RomanDA

Listing of other DX Tutorials: Click here
Today's Lesson: "User Input / Save / Retrieve"

In this lesson we will cover how to gather information from a user via a popup dialog box, and to how to store and retrieve this data from the registry.

As in the previous tutorial, the goal here is for you to learn how to create an object, add code to it, and be able to edit that code to make changes to the way the object/widget behaves. The code is provided for you to copy/paste, but it would work best if you type in the code, to see how DX "Auto-fills" the info as you type. Its really the best way to see how DX works.

In order to use these Tutorials you will need to purchase DesktopX for $14.95 from Stardock.

Lets get started.

STEP 1 - What are we doing here?
Why do we want to get input from a user?
Well that's all depends on the gadget/widget you are creating. For a Weather widget you need to get the City code or Zip code to use. If you have a "to-do list" widget, you would want to get the item they want to add into the list. There are a lot of reasons you need to gather input from the user.

Why store the data in the Registry?
I have picked using the Registry over using the built in functions because I have had issues with them not working 100% and they only work when you run it as a widget/gadget not in "builder" mode, and we want to see how this works. A lot of people do not like to send things to the Registry but I have not had any problems with this, some people have told me they needed to "allow" the program to write to the Reg, but after that it worked fine.

Alternatives:
You can store data in a TEXT file, an INI file, or even an XML file. Just about any place you want to store things. The problem with this is that you need to know the location of this file on the user's computer. This can cause problems, but there are a lot of widgets that use this method. I have used it as well, there are ways to cope with trying to locate the file. Not something I'm going to get into on this tutorial.

STEP 2 - Lets Get Started- Make a TEXT object.
As in the previous tutorials, I think you should know enough by now so that i can move past the every-single-step process.

Create a TEXT object.
Add the text "Click to Add Text"
Then pick the font/color/size that works best for you.
Once that is all done lets add a VERY simple script to allow you to ask for some input, and quickly show that info.

ADD the following at the bottom of the existing script items (Object_OnScriptEnter/Object_OnScriptExit)

Function Object_OnLButtonUp(x,y,dragged)
If dragged = False Then
x = InputBox("Please Enter A Piece of Text To Add to " & vbNewLine & object.text , "Add Some Text")
If x <> "" Then object.text = object.text & vbnewline & x
End If
End Function

Lets break the above apart.

Function Object_OnLButtonUp(x,y,dragged) This line creates a FUNCTION that is called when you RELEASE the "Left" Mouse Button, IE: when you click your mouse.
The X/Y/dragged are used to determine if you DRAGGED the mouse when you went to click the mouse.
If dragged = False Then we use this so that it wont activate the function every time you MOVE/DRAG the item around the screen.
Meaning, if the object is not dragged then run the function.
x = InputBox("Please Enter A Piece of Text To Add to " & vbNewLine & object.text , "Add Some Text") X is the variable we want to store the data into.
The INPUTBOX is used to prompt the user for "input".
the format is inputbox(message,title)

We are putting in a message:
"Please Enter A Piece of Text To Add to "
(existing text here)
Then we have a TITLE called "Add Some Text"
If x <> "" Then object.text = object.text & vbnewline & x If X <> "", which means if there is SOMETHING in the variable X then take the object.text and add the existing object.text and X to make a new piece of text.
the vbnewline puts a NEW LINE or linefeed after the existing text.
This will basically add the text the user inputs to the next line under the Existing Text.
End If
End Function
End the IF DRAGGED...
And end the Function.

The way this will work is very simple.
The original Text object shows:
Click to Add Text

When you click on the object you will see a dialog box like below:


Then you put in your text that you want to add "2nd Line of Text"

The next Object will now look like:

Click to Add Text
2nd Line of Text

You can keep adding more and more lines to the object.

This was simply to show you how to get "input" from the user.
The next step will be to take this data and store it somewhere.

STEP 3 - STORING User Entered Data
Using the same style entry box above we want to store a single piece of data into the registry.
To add this to the registry, we need to create a link into the Registry by using the WScript.Shell, we open a link.
Then we use the .REGWRITE command to send info to a particular part of the registry.

In this case we are going to use the "KEY" you see listed below. You could use just about anything.

The HKCU = HKEY_Current_User - you could use HKLM - for Local Machine. I prefer to use the Current User because this way each person could have their own settings on the machine.

As for the rest of the key, that is open to your desire, for now we want to use \Stardock\DesktopX\Widget\Tutorial6\SavedInfo

This can be done right in the previous code like this:


If x <> "" Then 
  object.text = object.text & vbnewline & x
  Set Sh = CreateObject("WScript.Shell")
  Sh.RegWrite "HKCU\SOFTWARE\Stardock\DesktopX\Widget\Tutorial6\SavedInfo", X
  Set Sh = Nothing
End If

This Just adds the value of X into the KEY "Saved Info".
Of course every time you run this it overwrites the info with the next piece of text you put into the INPUTBOX.

It would not look like what our text.object looks like now. So if you want it to match the widget's info with what you are storing in the registry just change the RegWrite line and replace the X with object.text

If we click on the widget, and add the "2nd Line of Text" to it, then we look in the registry we see the following in the KEY:



You can see the KEY at the bottom of the REG Editor, and see the value stored in "SavedInfo".

If you continue to add things, you will see this change, over and over.

STEP 4 - Retrieving the Data From the Registry
So, we stored the data into the Registry, and into the actual object (kind of dumb to do it in both, but it helps us see what's being stored).

Now we want to pull that data into another object. So lets make a new TEXT object, put in the text "Click to Restore" (you can save a LOT of time by "right-clicking" on the existing object and hitting "CLONE". This makes a duplicate object with all the same code already in place!)

We want to add a very simple script to this object.

Function Object_OnLButtonUp(x,y,dragged)
  If dragged = False Then
   Set Sh = CreateObject("WScript.Shell")
   On Error Resume Next
   X = Sh.RegRead("HKCU\SOFTWARE\Stardock\DesktopX\Widget\Tutorial6\SavedInfo")
   Set Sh = Nothing
   If X <> "" Then object.text = x
  End If
End Function

You will notice about 80% of this is the same. What is different is:

 On Error Resume Next
 --- This is used to keep the program working if the registry entry doesnt exist.
 X = Sh.RegRead("HKCU\SOFTWARE\Stardock\DesktopX\Widget\Tutorial6\SavedInfo")
 --- Pull the data from the KEY and store it in the variable X
 If X <> "" Then object.text = x
 --- In this case we want to make the entire Text object match what we stored
     in the registry key.  But we also want to Make sure that there was
     something in X from the registry.  Thus the "IF".

You could make a lot of modifications to this one, but it has a great base to build from.
An option would be to make a "function" or "SUB" that does the load and store.

CONCLUSION
There are a lot of usages for these items. Anytime you want to get user info, or store/retrieve data from the registry you now know what to do.

Keep in mind that you can read in ANY "KEY" from the registry, so you could easily modify this to pull in the data in the key for say... Who the "Registered Owner" of the pc is

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\RegisteredOwner

There are lots of things you could pull from the reg. and update as well. SO PLEASE PLEASE PLEASE Take care when you write to the registry.

Check back as I add new Step-By-Step Tutorials on how to make this a link to a folder, web-site, or just about anything you want!

I hope you have enjoyed this step into DX, and look forward to the next installment.

Enjoy,
RomanDA
http://romanda.wincustomize.com

Learning DX Step-By-Step - #5

Using WMI

Thursday, April 5, 2007 by RomanDA | Discussion: DesktopX Tutorials

Step-by-Step Tutorials

#5 - Using WMI

A series by RomanDA

Listing of other DX Tutorials: Click here
Today's Lesson: "Using WMI" Windows Management Instrumentation

In this lesson we will cover how to use Microsoft's WMI to find out some basic info about our windows computer.
In order to use these Tutorials you will need to purchase DesktopX for $14.95 from Stardock.
Lets get started.

STEP 1 - Create a text object.


I'm not going to go back over the first 4 tutorials, if you haven't read them, and gone thru them, please go back and do that first.

Create a TEXT objet, make the default text something like "TEST" it doesn't matter, make it the size you want (big enough to read on your screen).

 

We are simply going to be using this text object to display the info we gather.  Again, this is just to show you HOW to use WMI to retrieve info from your computer, not how to make a pretty widget.  We can do that later. 

 

Don't worry about adding scripts yet, we will do that in a later step.

STEP 2 - WMI Basic connection


WMI is used to pull information from your system, things like Computer name, User name, What drives are attached to your system.  We are going to pull this information from your computer using a simple script in DX.

Open your object, click on NEW for the script.
We will be adding some info to the "Sub Object_OnScriptEnter"
 

Vbscript  Code
  Dim objWMIService
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set compinfo = objWMIService.ExecQuery ("Select * from Win32_ComputerSystem")
 
The DIM is used to Declare variables and allocates storage space.
The first SET command is used to make the connection to the local computer.  I could get all technical on this part, but if you really want to know all the details on this connect string visit this site.
The 2nd SET command is used to pull the information you want from the computer.  In this example we are wanting to get the user name, domain name, and computer name.  This works like a SQL Query string, there are a ton of options for this as well.  Again, this is a BASIC tutorial, so if you want more details, look the commands up.

Lets break this line apart:
Set CompInfo Set the variable CompInfo to the info we pull from WMI
objWMIService objWMIService was setup in the previous SET command to
point to the WMI service.
.ExecQuery ( Execute a query into the WMI database
"Select * we want to "SELECT" * - EVERYTHING
we could have picked just 1 item if we only wanted say the Username, etc.
from Win32_ComputerSystem") The data we want is coming from the Win32_ComputerSystem part of WMI
There are DOZENS of these tables in WMI.

HERE is a great place to learn all about WMI
 Lets look at what information we can pull from this one table:
I'm not going to go through ALL of this, I just want you to see what is available from this 1 table.
 
WMI Information
  class Win32_ComputerSystem : CIM_UnitaryComputerSystem
{
  uint16 AdminPasswordStatus;
  boolean AutomaticManagedPagefile;
  boolean AutomaticResetBootOption;
  boolean AutomaticResetCapability;
  uint16 BootOptionOnLimit;
  uint16 BootOptionOnWatchDog;
  boolean BootROMSupported;
  string BootupState;
  string Caption;
  uint16 ChassisBootupState;
  string CreationClassName;
   sint16 CurrentTimeZone;
   boolean DaylightInEffect;
   string Description;
   string DNSHostName;
   string Domain;
   uint16 DomainRole;
   boolean EnableDaylightSavingsTime;
   uint16 FrontPanelResetStatus;
   boolean InfraredSupported;
   string InitialLoadInfo;
   datetime InstallDate;
   uint16 KeyboardPasswordStatus;
   string LastLoadInfo;
   string Manufacturer;
   string Model;
   string Name;
   string NameFormat;
   boolean NetworkServerModeEnabled;
   uint32 NumberOfLogicalProcessors;
   uint32 NumberOfProcessors;
   uint8 OEMLogoBitmap[];
   string OEMStringArray[];
   boolean PartOfDomain;
   sint64 PauseAfterReset;
   uint16 PCSystemType;
   uint16 PowerManagementCapabilities[];
   boolean PowerManagementSupported;
   uint16 PowerOnPasswordStatus;
   uint16 PowerState;
   uint16 PowerSupplyState;
   string PrimaryOwnerContact;
   string PrimaryOwnerName;
   uint16 ResetCapability;
   sint16 ResetCount;
   sint16 ResetLimit;
   string Roles[];
   string Status;
   string SupportContactDescription[];
   uint16 SystemStartupDelay;
   string SystemStartupOptions[];
   uint8 SystemStartupSetting;
   string SystemType;
   uint16 ThermalState;
   uint64 TotalPhysicalMemory;
   string UserName;
   uint16 WakeUpType;
   string Workgroup;
  };

What we want from this table is:

  • UserName  - User Name
  • TotalPhysicalMemory - Total Memory
  • Domain - Domain name (If there is one)
  • Name - Computer Name

STEP 3 - Pulling info from WMI


So, we know how to make the connection to WMI, and we know what table we want.
Lets get the USERNAME that is logged into the current computer.
 

Vbscript  Code
  For Each objComputer In CompInfo
  PCName = objComputer.Name
  Next
  object.text = "ComputerName: " & PCName

Let's look over this one too.

I'm not going to break everything apart, but the basics are this:
the FOR EACH is used to pull 1 item at a time from the COMPINFO we set before, and store it in the objComputer variable. 
Then we assigning the variable PCName to the .NAME field from the table.
Then we take and set the TEXT of the object to "ComputerName: " & PCName

SAVE & APPLY this now, and see what happens.
What you SHOULD see is your text object showing something like:
ComputerName: MyPcsName

Not to hard was it?  Lets add a little more.
 

STEP 4 - Adding more info


Open the object back up, EDIT the script.  Lets add a little more info.
 

Vbscript  Code
  For Each objComputer In CompInfo
  PCName = objComputer.Name
  PCDomain = objComputer.Domain
  UserName = objComputer.UserName
Next
  object.text = "ComputerName: " & PCName & vbnewline
  object.text = object.text & "Domain: " & PCDomain & vbnewline
  object.text = object.text & "UserName: " & UserName & vbnewline

We added the Domain name (if there is one, you may not have one), and the Username.
Notice the USERNAME has the domain name as part of it? (if you have a domain, otherwise you wont see this).
We want to pull JUST the user name out from that. So lets add a simple IF statement to the script.

Vbscript  Code
  If len(PCName) > 1 Then
  t = len(PCName)+2
  UserName = mid(UserName,t)
End If

Insert this script right below the UserName = objComputer.UserName line.
This simply looks at the PCName to see if its LENgth is over 1 character
Then it gets the length of that name + 2 spaces (the \ and then the first letter of the name)
Then it sets UserName to the MIDdle of the the string UserName starting at the T postion.

Don't worry I will put the entire script at the bottom in one place, so you can copy/paste it if you want.

STEP 5 - What Drives do we have?


We are going to add a little more to this script.  One of the things people have asked to see is how to determine what drives, drive letters, etc. are on your pc.

 

The code we are going to add looks a lot like what we used above:
 

Vbscript  Code
  Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set DriveInfo = objWMIService.ExecQuery ("Select * from Win32_LogicalDisk")
object.Text = object.Text & vbnewline & "DeviceID | DriveType | Description "
object.Text = object.Text & " | VolumeName | FreeSpace | FileSystem"
For Each objDrive In DriveInfo
  object.Text = object.Text & vbnewline & objDrive.DeviceID & " | "
  object.Text = object.Text & objDrive.DriveType & " | " & objDrive.Description
  object.Text = object.Text & " | " & objDrive.VolumeName & " | "
  object.Text = object.Text & objDrive.FreeSpace & " | " & objDrive.FileSystem
Next

We are pulling a lot of info from the WIN32_LogicalDisk table.  add the code, see what shows up.
You should see something like:

DeviceID | DriveType | Description | VolumeName | FreeSpace | FileSystem
C: | 3 | Local Fixed Disk | Boot-2006b | 30640107520 | NTFS
D: | 3 | Local Fixed Disk | Storage-2006b | 14589018112 | NTFS
E: | 5 | CD-ROM Disc | 20030803_1304 | 0 | CDFS
F: | 5 | CD-ROM Disc | | |

STEP 5 - Here's The code:


Promised to post all the code in one place, here it is:

Vbscript  Code
  'Called when the script is executed
Sub Object_OnScriptEnter
 Dim objWMIService
 Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
 Set CompInfo = objWMIService.ExecQuery ("Select * from Win32_ComputerSystem")
 For Each objComputer In CompInfo
  PCName = objComputer.Name
  PCDomain = objComputer.Domain
  UserName = objComputer.UserName
  If len(PCName) > 1 Then
   t = len(PCName)+2
   UserName = mid(UserName,t)
  End If
 Next
 object.text = "ComputerName: " & PCName & vbnewline
 object.text = object.text & "Domain: " & PCDomain & vbnewline
 object.text = object.text & "UserName: " & UserName & vbnewline

 Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
 Set DriveInfo = objWMIService.ExecQuery ("Select * from Win32_LogicalDisk")
 object.Text = object.Text & vbnewline & "DeviceID | DriveType | Description "
 object.Text = object.Text & " | VolumeName | FreeSpace | FileSystem"
 For Each objDrive In DriveInfo
  object.Text = object.Text & vbnewline & objDrive.DeviceID & " | "
  object.Text = object.Text & objDrive.DriveType & " | " & objDrive.Description
  object.Text = object.Text & " | " & objDrive.VolumeName & " | "
  object.Text = object.Text & objDrive.FreeSpace & " | " & objDrive.FileSystem
 Next
End Sub

CONCLUSION


There are a lot of things that can be done with this info.  Things like making a Drive monitor, or a simple piece of text with your username etc on it.
WMI is EXTREMELY powerful, you can pull things from other computers on your network, A simple GOOGLE search will show you TONS of places with lots of script examples. 

Check back as I add new Step-By-Step Tutorials on how to make this a link to a folder, web-site, or just about anything you want!

I hope you have enjoyed this step into DX, and look forward to the next installment.

Enjoy,
RomanDA
http://romanda.wincustomize.com

Learning DX Step-By-Step - #3

Tutorial #3 - Attack of the Clones

Thursday, February 22, 2007 by RomanDA | Discussion: DesktopX Tutorials

Step-by-Step Tutorials

#3 - Attack of the Clones

A series by RomanDA

Listing of other DX Tutorials: Click here

Today's Lesson: "Attack of the Clones"

In this lesson we will cover how to create a clone from an object, so we can have multiple items on the screen linked to a Folder, a Program and a web URL.

In order to use this tutorial, you will need to first go thru Tutorial #2 (and download the zip file from there as well).

I will assume you downloaded the zip of the png files, followed the Tutorial #2, and are ready to take your Lightbulb and make a new one that will point to a Program and another to a URL.

For this and all the Step-By-Step DX Tutorials you will need to purchase DesktopX for $14.95 from Stardock.

Lets get started.

STEP 1 - Cloning the Lightbulb
Again, I know this is redundant but you need to have completed Tutorial #2 before you attempt this one. That said, we will take our lightbulb and make a clone:
  • RIGHT CLICK on the light bulb, and you will be presented with a menu of options.
  • Select CLONE OBJECT(S)
  • You should see the following now:

You have just created a CLONE!! *** Repeat this step one more time so that you end up with 3 lightbulbs ***

STEP 2 - Point your Clone to a Program
  • Pick one of the clones and RIGHT-CLICK on it
  • Select PROPERTIES
  • Follow the steps below to select a program to run:
    1. Click CHANGE next to the OBJECT TYPE (Shortcut)
    2. Select the FILE SHORTCUT
    3. BROWSE for a file to use
      • use the dialog box to select whatever file you want to run
      • I will let you select the file, its your call.
    4. Select OK on the Browse Dialog Box
    5. Select OK on the PROPERTIES Dialog Box
  • To test this out, simply click on the Lightbulb and see if it loads your program.
STEP 3 - Adding a TOOL-TIP to these so you know which one is which
Ok, you have 2 identical (well 3 really) clones on your desktop. So that you can know which one does what, we are going to add a TOOL-TIP (the text that shows up when you mouse over something) to each.
  • RIGHT-CLICK on the the FIRST OBJECT (the one that points to the FOLDER) select PROPERTIES
  • Click on the SUMMARY Tab
  • Click in the area next to TOOLTIP and type in MY DOCUMENTS FOLDER (or whatever folder name you chose to use)
  • Click OK
  • To test this move your mouse OVER the lightbulb and you should see:
  • REPEAT THIS ON THE OTHER 2
    • Make one's tooltip - MY PROGRAM NAME (using the name of the program you picked)
    • Make the other one's tooltip - WINCUSTOMIZE.com (thats where we are going to point that one)
  • This will give you different tooltips on each one now (i hope)
STEP 4 - Making a URL Linked Object
  • RIGHT-CLICK on the 3rd Clone and select PROPERTIES
  • Follow the steps below
    1. CHANGE next to the OBJECT TYPE (Shortcut)
    2. Pick URL from the dropdown
    3. Enter https://www.wincustomize.com into the url area
    4. Select OK
    5. Select OK
CONCLUSION

Ok, That wasn't hard was it? Ok, yeah so now you have these 3 HUGE lightbulbs on your desktop, and they suck, well make your own images, and change them! Changing them is simple, go back to Tutorial #2, look at step #3 and just pick your own images for "mouse over" and "mouse away" states.

You can even download from the MISC Icons library and use them for these states.

Check back as I add new Step-By-Step Tutorials on how to make this a link to a folder, web-site, or just about anything you want!

I hope you have enjoyed this step into DX, and look forward to the next installment..

Enjoy,RomanDA
AKA: David A. Roman
http://romanda.wincustomize.com

Learning DX Step-By-Step - #2

Tutorial #1 - Folder Object

Thursday, February 22, 2007 by RomanDA | Discussion: DesktopX Tutorials

Step-by-Step Tutorials

#2 - Folder Object

A series by RomanDA

Listing of other DX Tutorials: Click here

Today's Lesson: "Folder Object"

In this lesson we will cover how to create a simple object that you can use to open a folder. (We will be using this in the next one to create a Program and a URL Shortcut.

To use this tutorial you will need these 2 PNG files - click HERE to download - (yes, they are lame, but i wanted something simple to use).

For this and all the Step-By-Step DX Tutorials you will need to purchase DesktopX for $14.95 from Stardock.

Lets get started.

STEP 1 - Load DesktopX
Once you have DesktopX installed, look in your Start Menu for "Object Desktop" then for "DesktopX", click it to load the program.

You will see the DesktopX STARTUP Screen (yours wont say PROFESSIONAL unless you purchased PRO) One you see this screen, click on "CREATE" because we want to CREATE a new Widget.

It will load the DesktopX SETTINGS Window:

We just wish to get these screens out of the way for now, we are not going to use them. Click "CANCEL" on the SETTINGS window, and DONE on the STARTUP Screen.

You should have a blank screen now with a new icon in your system tray:

STEP 2 - Create an object
RIGHT CLICK on the icon in your system tray and you will see a popup menu like this one:
You will need to select the "NEW OBJECT" item on this menu.
You will see the OBJECT PROPERTIES window below (as well as the object itself). This window will be referenced over and over in these tutorials. IE: Open Properties / Select States (which would mean to select the States TAB in the Properties window)

You can access this properties window at any time by RIGHT-CLICKING on the object and selecting PROPERTIES.

STEP 3 - Adding Images into the Object
When you added the object, it brought up the PROPERTIES window, now select the "STATES" tab to change to this TAB.
  • In this window, select BROWSE, then select the LIGHTBULB-OFF.png file from the zip file at the top of this article.
  • Click OPEN
  • On the OBJECT PROPERTIES, click APPLY
  • You should see this:

  • Click on ADD... in the PROPERTIES dialog above, you will see this window:
  • Click OK for the mouse over default.
  • We are going to repeat the steps above to select the LIGHTBULB-ON.png:
    • click BROWSE
    • Select the LIGHTBULB-ON.png file.
    • Click OK
    • Then click OK in the PROPERTIES Dialog - this will close the PROPERTIES Dialog Box
  • You really wont see much happen until you move your mouse OVER the light bulb, when you do, it should look like this:
  • You have now created an object with 2 states, mouse OVER and mouse AWAY (or normal).
STEP 4 - Making your Lightbulb DO something.
  • RIGHT-CLICK on the new Object and select PROPERTIES
  • We are going to point this one to a folder on your computer.
  • Follow the Step #'s in the image below
    1. Click CHANGE on the OBJECT TYPE Button
    2. Click on the DROP-DOWN at the top of the COMMAND TYPE Dialog, select SHORTCUT
    3. Select FOLDER SHORTCUT
    4. Select BROWSE
      • Select you MY DOCUMENTS (or whatever folder you want to open) from the dialog box (see below)
      • Click OK to accept the folder you selected
    5. Click OK on the COMMAND TYPE DIALOG box
    6. Click OK on the OBJECT PROPERTIES Dialog box
  • You now have created a Shortcut icon to the Folder you selected.
  • CLICK on the Lightbulb and it should open the folder you selected.
STEP 5 - Changing the CURSOR on the Lightbulb
  • When you move over the Lightbulb you want to show that it does something, and to do that we will change the cursor to a HAND, so that it looks like we can click it.
  • RIGHT-CLICK on the new Object and select PROPERTIES
  • Select the RELATION Tab
  • In the CURSOR Dropdown, select HAND
  • Click on OK (this will close the dialog box)
  • Test this by moving your mouse over the lightbulb, you should see: - Notice the HAND Cursor
CONCLUSION
This is a pretty simple Tutorial, I was going to continue this and make several clones of the lightbulb for a program and a url, but I want to split that into the next Tutorial. I will post that at the same time I post this, so you can continue with Tutorial #3 - Attack of the Clones

Check back as I add new Step-By-Step Tutorials on how to make this a link to a folder, web-site, or just about anything you want!

I hope you have enjoyed this step into DX, and look forward to the next installment.

Enjoy, RomanDA
AKA: David A. Roman
http://romanda.wincustomize.com

Controlling Groups

Beginner

Monday, January 22, 2007 by sViz | Discussion: DesktopX Tutorials

In this tutorial we’ll look at how to control groups through scripting, and how to control several objects as a group even if they are not grouped, and we’ll start by a brief look at how to control groups through object properties.


Toggling a group of objects on and off (show/hide) through object properties is not hard. You just need to group your objects and create another object as an object controller. Like what you see below.




In the properties of the group controller, change the object type to ‘object controller’. In the command type dialog set it to open/toggle, and then in the drop down choose the name of the group.



Folks, it’s that easy. Further configurations can be made in the group objects themselves under Properties > Relation > Popup as explained in the Developer’s Guide here—Link

I know you’re looking at the command options in that object controller and you’re thinking, can’t I control more than show/hide? Well, maybe you’re not but the answer is—YES! With simple scripts you can move the entire group, change the color of all the objects in the group, re-arrange the group, and yes, you can still show and hide the group, too!

Let’s get started.

Change the group controller’s object type back to ‘Layer’ because that’s where we’ll put the script.

When scripting groups, the For Each statement is extremely useful. This statement basically tells DX to do something for each object in the group. In this statement each object is called ‘elem’ and you can assign it most normal properties (e.g. object.text / elem.text, object.hue / elem.hue etc.) such as explained in the DevGuide here – Link

Here are some scripts for you to try (my group’s name is “testgroup”).


TOGGLE (SHOW/HIDE) SCRIPT:

Sub Object_OnLbuttonUp(x,y,dragged)
If Not dragged Then
For Each elem In Desktopx.GroupObjects("testgroup")
If elem.visible = True Then
elem.visible = False
ElseIf elem.visible = False Then
elem.visible = True
End If
Next
End If
End Sub


MOVE GROUP SCRIPT:

Sub Object_OnLbuttonUp(x,y,dragged)
If Not dragged Then
For Each elem In Desktopx.GroupObjects("testgroup")
elem.left = elem.left + 2
Next
End If
End Sub


CHANGE COLOR SCRIPT:

Sub Object_OnLbuttonUp(x,y,dragged)
If Not dragged Then
For Each elem In Desktopx.GroupObjects("testgroup")
If elem.hue=> 255 Then
elem.hue = 0
Else
elem.hue = elem.hue + 15
End If
Next
End If
End Sub



Simple, no?

Now, what if you don’t want your objects in a group? After all you might want them to move independently. Ungroup the grouped objects and insert the script below into the group controller:

TOGGLE SEVERAL OBJECTS:

Sub Object_OnLbuttonUp(x,y,dragged)
If Not dragged Then
‘Check if one of the objects are already hidden or showing
Select Case Desktopx.Object("1").visible
Case True
showhide= False
Case False
showhide= True
End Select
'Set objects visibility
Desktopx.Object("1").visible = showhide
Desktopx.Object("2").visible = showhide
Desktopx.Object("3").visible = showhide
End If
End Sub


MOVE SEVERAL OBJECTS:

Sub Object_OnLbuttonUp(x,y,dragged)
If Not dragged Then
Desktopx.Object("1").top = Desktopx.Object("1").top + 2
Desktopx.Object("2").top = Desktopx.Object("2").top + 2
Desktopx.Object("3").top = Desktopx.Object("3").top + 2
End If
End Sub


Obviously, when you think about it, if you had A LOT of ungrouped objects you wanted to control, listing them would be laborious and tweaking one small aspect would be painstaking. Trust me, I know. Before I got the hang of scripting I used this method ad nauseam and every time I wanted to make a change I had to go through the entire list—several times! There is an easier way. This method uses the For Next statement and is facilitated by how you name the objects you want to control. I use this method a lot as I did in my Scrolling Text tutorial Link , here I’ll explain it some more.

First, rename your objects like this:
object1, object2, object3 OR item1, item2, item3 (not item01, 02, 03 etc.)



Whatever name you use make sure you name the other objects the same and in serial order. This is important. It is also important to define the number of objects you are controlling. We’ll use the variable numofobjs to do this. Insert the script below into the group controller.

Dim numofobjs
'Define number of objects to control
numofobjs = 3

Sub Object_OnLbuttonUp(x,y,dragged)
If Not dragged Then toggle
End Sub

Function toggle
'Check the visiblity of object
Select Case Desktopx.Object("object1").visible
Case True
showhide= False
Case False
showhide= True
End Select
'Reset visibility of objects
For x= 1 To numofobjs
desktopx.Object("object" & x).visible =showhide
Next
End Function



Now what does this mean:

For x= 1 To numofobjs
desktopx.Object("object" & x).visible =showhide
Next

For Next is basically a loop that will start at 1 and do whatever code is in between as many times as you define in numofobjs; that’s 3 times. So it goes from 1 to 3.
X is a variable that will change on each loop. On the 1st loop x=1, on the 2nd loop x=2, and on the 3rd loop x=3.
So when you add ‘x’ to the object name here: (“object” & x) you will get “object1” on the first loop, “object2” on the 2nd loop and “object3” on the 3rd loop. So, on each loop you set the visibility of a different object! It’s nice and streamlined and much easier than listing each object line after line.



The end! Thanks for reading.

DX Tutorial #6: Date/Time Widget - PART 1

Creating your first DX Widget Step-by-step! - PART 1

Wednesday, August 16, 2006 by RomanDA | Discussion: DesktopX Tutorials

RomanDA's DekstopX Tutorials:
My goal is to make a set of tutorials for DekstopX.  If you have ideas on what you would like to see, please email me at DXTutorials@RomanDA.org

Time/Date & more  - PART 1:
I have been asked about a dozen times how to get this or that date info into an object.  So I will try and cover that here.
This is not my typical tutorial, this will be a STEP-BY-STEP Creation of a widget, not just some code.

DOWNLOAD THE ZIP FILE FOR THIS TUTORIAL FIRST!

DekstopX can use JavaScript or VBScript as its language, I am a LOT more familiar with VBScript then JS so that is what I use.
As always, I'm sure there are other, if not better ways to do this, but this is my way.

The Players:
  Here are the objects we will be setting up:
 (forgive me Danniloc as some of this was from our conversation - the graphics are mind but look like the one your working on):
 
BASE Object:
This will have the text objects a children as well as run the script.
MonthName Month object will show the current month
Date Date object will show today's date
Year Year object will show the current year
DayOfWeek Day Of Week object will show the current day of the week in text form "Monday" "Tuesday" etc.
Time Time object will show the current time.

Creating the Objects:
  For those of you that have never used DX this is not hard, I will walk you through creating the above object.

LOAD DekstopX and go into the CREATE mode:
* if you do not have DekstopX (builder) you will need to download it.
BASE OBJECT:
  Create the BASE object by
  RIGHT-CLICK on the DekstopX Icon in the system tray.

Select "New object"

<-- See this for more info

  The Object Properties Dialog will show up.

Click the "States" Tab

  Click the "Browse" Button.
  Select the "Frame-Green.png" File from the 6-DateWidget.zip file here.

Select "Open"

Click "OK" in the "Object Properties" Dialog box.

  You should now see your FRAME or BASE object.

 

  RIGHT CLICK on this object and select "Properties".
  In the Object Properties dialog, select the "Summary" tab

 

In here we will change the following:

Object ID: BASE

Group: DateWidget

Widget: DateWidget

If you want you can add your name to the "Author" Section.

 

When done editing these, click the "OK" Button.

OTHER OBJECTS:
  We will follow the same above steps to create the TEXT objects but there will be a few minor change.
I'm not going to re-post all the same images, see above if you get lost.

DayOfWeek Object

  RIGHT-CLICK on the DekstopX Icon in the system tray.

Select "New object"

  Select the "States" Tab

In there select "TEXT" not "IMAGE" from the Appearance Tab.

Type in "Monday" in the provided text area

Select Alignment: CENTER

Click on Font and select a font you like, I like Tahoma, you can pick whatever you want, be advised the size, and font will make some of the next screen shots look strange, for now pick Tahoma and 12 and bold,  you can come back later and change it.

Select OK on the Font Dialog.

Select the Color Button, select a dark color something that will look good on the white background (or gray), I'm picking a dark gray.
Select OK in the Color dialog box

 

  In the Object Properties dialog, select the "Summary" tab

In here we will change the following:

Left: 0

Top: 20

Width: 150

Height: (image default)

Object ID: DayOfWeek

Parent/Owner: BASE

Child: YES

Group: DateWidget

Widget: DateWidget

 

When done editing these, click the "OK" Button.

  This should be your new widget

Congrats, its beginning to look like something.

  MonthName Object  
  Follow the exact same steps from above except this time you will put in:

"August" in the text area, and the following in the Summary Tab:

  In the Object Properties dialog, select the "Summary" tab

In here we will change the following:

Left: 0

Top: 44

Width: 150

Height: (image default)

Object ID: MonthName

Parent/Owner: BASE

Child: YES

Group: DateWidget

Widget: DateWidget

 

When done editing these, click the "OK" Button.

  Your new object should look like this now.
  Date Object  
  Follow the exact same steps from above except this time you will put in:

"16" in the text area
Make the font 14 not 12
and change the following in the Summary Tab:

  In the Object Properties dialog, select the "Summary" tab

In here we will change the following:

Left: 0

Top: 66

Width: 150

Height: (image default)

Object ID: Date

Parent/Owner: BASE

Child: YES

Group: DateWidget

Widget: DateWidget

 

When done editing these, click the "OK" Button.

  Your new object should look like this now.
  Year Object  
  Follow the exact same steps from above except this time you will put in:

"2006" in the text area
Make the font 12 not 14
and change the following in the Summary Tab:

  In the Object Properties dialog, select the "Summary" tab

In here we will change the following:

Left: 0

Top: 92

Width: 150

Height: (image default)

Object ID: Year

Parent/Owner: BASE

Child: YES

Group: DateWidget

Widget: DateWidget

 

When done editing these, click the "OK" Button.

  Your new object should look like this now.

See we are getting there.

IF you have done everything correct up to this point, you should be able to "DRAG" this around, and everything should move as 1.

If something moves that shouldn't you will need to RIGHT-CLICK on that object, hit Properties, then make sure that the Group and Widget are both "DateWidget".  then check it again.

  Time Object  
  Follow the exact same steps from above except this time you will put in:

"10:16 am" in the text area
Make the font 12
and change the following in the Summary Tab:

  In the Object Properties dialog, select the "Summary" tab

In here we will change the following:

Left: 0

Top: 140

Width: 150

Height: (image default)

Object ID: Time

Parent/Owner: BASE

Child: YES

Group: DateWidget

Widget: DateWidget

 

When done editing these, click the "OK" Button.

  We are now done creating objects.

Your widget does nothing at this point except show the text we put into it.

Its time to start making this thing WORK.

Please look at Part 2 for the continuation of this tutorial, and PLEASE let me know if you find these useful.

Enjoy,
RomanDA
AKA: David A. Roman
http://romanda.wincustomize.com
http://www.romanda.org
DXTutorials@RomanDA.org



web-wc01