RomanDA's World of Gadgets
Contact me if you are looking for custom Gadgets or for help with DX projects.
View
Search

Sep 12, 2013 4:50 PM by Discussion: DesktopX

After a very long time of little to no activity on any of my MASTER Gadgets and on my website Commercial Gadgets, I have decided to shut it all down.

I have deleted all my Master Gadgets from WC.  If anyone wants anything I might be willing to reupload things for free.

I will NOT be reuploading the Holiday Countdown PRO as it has been nothing but a royal pain in my butt for years now.

Since spending MONTHS coding it, and having all that VANISH in the blink of an eye, to Having it no longer work on "some" Vista and Win 7 boxes (not all).  I have spent hundreds of hours on this one gadget.  In all that i think i have sold a total of 20 of them. at $2-3 of "profit" on my end, meaning i was working for less then pennies an hour.

My commercial gadgets site was doing ok for the first year or two, but without the time to devote to things I have not added anything new, or looked at any of the gadgets on there since 2009.

Its sad that DX4 never really materialized as i might have been interested in seeing how that would have worked out (not bitching, i fully understand the climate and business decision).  I do use DX a good bit for my job, and it has served me well for all these years.  

I want to thank everyone who supported my work, helped me with testing, and bought anything of mine.

As of today, I will no longer be supporting any of my gadgets.  If it works, yeah, if not, oh well.

I cant put that time into this when i could be using it to do something that is much more productive to my future.

I may from now and then still check on things here, and if you need DX help leave me a msg.

One thing that this is probably going to do is break all the Tutorials I worked so hard on.  As they all point to my Commercial Gadgets website for the images. These are all going to be gone by the end of the day (the images, not the Tuts).  If someone at SD/WC wants to move them to their servers somehow im fine with that.  (Let me know).

 

I really did enjoy my years spent on DX.  

Thanks again all!

David

 

If you didnt know, I'm heavily into photography now, at both my facebook page: https://www.facebook.com/RomanDAPhotography
and my personal web page: http://romandaphotography.com/

Please LIKE my FB page and leave me a message so we can keep up.

28 Replies Reply 22 Referrals

Aug 2, 2012 10:37 AM by Discussion: Community

I am trying to win a canvas print of one of my photos, and its a really really simple contest.

I just need 25 Re-Tweets.

1. Follow me here (which im sure you want to do anyway, 'cause im taking some cool pics you want to see): https://twitter.com/RomanDAPhoto

2. Retweet the post on my feed: Need Help PLZ RT: Instagram photos online ( ) and create your own business in less than one minute!  

Thats it, all done.

What do you get out of this?

 1. The great feeling that comes from helping others.

 2. Ill give each person a free copy of any of my master DX gadgets, just post here a screen shot of your RT and what one you want, and ill MSG you a way to download it.

 3. my thanks!

Thanks again all!

RomanDA

18 Replies Reply 7 Referrals

Jul 20, 2010 11:40 AM by Discussion: WinCustomize Talk

hey all.. yeah im still alive.. i think...  Been working too dang much and not able to do any dx stuff or much of anything else these days.

I have a favor to ask.  I have a photo of some friends and we wanted to make it look like they had torches in their hands (some) and that the house behind them was on fire.  I have very LITTLE skill in this area, and thought that someone might be bored and want to help me out with this.

Im really trying to do this fast as its a gag for the people who's house we were in. They are out of town and we wanted to mess with them. 

I know there are a lot of you that could do this pretty simply and fast (i suck at this stuff).  Just thought id throw this out to the people i thought could pull it off.

burning down the house

So lets see.. people with "sticks' should have "torches".. the kid in the chair needs to be "tied" up - not gaged.

The guy on the right should have a sword maybe?

The woman in the middle at the top should be "pouring something" on the kid in the middle.

Here is the link to the full sized file

I know im asking a lot.. but i just thought someone out there had the time and talent and would like to help me out.

Thanks in advance!

David - aka: RomanDA

 

18 Replies Reply 6 Referrals

Jun 18, 2009 5:17 PM by Discussion: DesktopX

I am working on a few new gadgets, or possbily a dxpack.  its nothing special, but i have not done a whole lot in a while, and wanted to see what people thought.  

The idea is to have several "desktop level" items (calendar/date-time-clock/and pc stats) all with a high transparancy, and kind of blending into the bg.  This is just a test.  Eventually you would be able to change each "sections" font color/transparancy.  So if you have a light/dark bg you could have the cal dark and the other items light, etc.  Its no way ready for anything.   I saw someone had a program that edited the wallpaper and added "info" to it, but you would have to update that every time you wanted to see the updated stats.  With this i was thinking of updating the main info every 30 mins, the cal gets updated every min or so, and the clock is every second.  There is also a cpu info hiding in the stats that is updated every 10-20 seconds.  I dont want this to use a lot of cpu cycles.  and im pretty sure someone else has done something just like this, but i wanted something to play with.

Let me know what you think, slam it, love it, whatever.  Give me some ideas on what you would like to see added.  Again, dont expect this for a while, im busy as crap at work, and im trying to head out of town for a VACATION in July so this will be something i play with when i can.

 

Enjoy.

5 Replies Reply 2 Referrals

Stepping Thru States

Jan 14, 2009 12:23 AM by Discussion: DesktopX Tutorials
Step-by-Step Tutorials

#12 - Stepping Thru States

A series by RomanDA

Listing of other DX Tutorials: Click here

Today's Lesson: "Stepping Thru States" is a very simple way to setup multiple states with a button to change between them.

In this lesson we will cover how to create a simple object, then add multiple states to it, and add a simple button to "step" thru the states.

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

See previous tutorials for how to load DX & create a new object.

Lets get started.

 
STEP 1 - Create the first object "state"
With DX loaded and running, add a new object, goto the "STATES" tab and here we will assign the object a new image and then rename the state to "1"

Browse to the 1st background image you want to use, and select it.
Then use the steps below to rename the state to 1.

RIGHT-Click on the
"Mouse Away" in the States window. 
Click "Rename" and name the state "1".

We will be adding more states in the next step, and each one will be another # .  IE: 2, 3, 4, 5.
 
STEP 2 - Create More States 
Add a new STATE naming it "2" and assigning it to the next background image.

You would continue this for ALL the states you want to add.

In our case we will make the TOTAL 8 states.

Repeat - till you have all 8 states added.

"OK" it all when its done.
 
 
STEP 3 - Adding the code to step thru the states.

Edit the above object and click on "NEW  SCRIPT". We will be adding the following script.

[code="vbscript"]

Dim MaxStates, CurrentState

'Called when the script is executed
Sub Object_OnScriptEnter
MaxStates = 2 '-- Set this to the max # of states
'-- Pull Current State from object
CurrentState = Object.PersistStorage("CurrentState")
'-- check CurrentState to see if it had any value
'-- if not set it to 1
If len(CurrentState) = 0 Then
CurrentState = 1
Widget.AddPreference("CurrentState")
Widget.Preference("CurrentState").defaultvalue = 1
End If
Call SetState() '-- See Function Below
End Sub


Function SetState()
object.state = CurrentState
End Function



Sub Object_OnLButtonDown(x, y)
CurrentState = CurrentState + 1
If CurrentState > MaxStates Then CurrentState = 1
Call SetState()
Widget.Preference("CurrentState").value = CurrentState
End Sub


'Called when the script is terminated
Sub Object_OnScriptExit

End Sub

[/code]

 

You could also add multiple "state" changes to other objects as well (things like Clock hands, or color changes to text objects, etc.
CONCLUSION
There is a lot more you can do with this, but these are the basic steps to setting up the Stepping Object State Changer.

This works great for clocks, and lots of other items where you want to have multiple looks/colors/layouts.

Enjoy,RomanDA
AKA: David A. Roman
http://romanda.wincustomize.com
29 Replies Reply 21 Referrals

Date and Flames

Nov 1, 2008 3:30 PM by Discussion: DesktopX Tutorials

Ok all.. lets add a few more little details.

FLAMES:

I made a small PNG (its not great im not a great graphics guy) with 4 states to it that when put into DX and be "animated".

Here is what it looks like when cloned 5 times (and shrunk to death!).

Steps:

  • Create new object called FlameBG
  • I used the 5x5 blank i made in the first part for the background image, set its transparancy to about 5
    for now, it will be 0 when its done.
  • I positioned this box so that it would be big enough to cover the candles so that i could make the flames
    Children of this box, and then i would be able to "move" the box for the mini and large backgrounds.
  • I made a new object called "Flame1" and made its animation state as shown:



  • I Cloned the flames 4 more times.
  • In order to make the flames look a little different, i made one's animation "style" set to "forward" then "backward" then "f + b" then "b + f".
  • I made them all "children" of the FlameBG object, and positioned them over the candles.

Now for some more code:
In order to make the FlameBG move, i had to position it for the Large and the Mini cakes, and write down the top/left position for each background.  Then I modified the code to move this when you clicked the mini/large buttons.
FT = Flame top, FL = Flame left

[code="vbscript"]
Function SetMode(Mode)
  desktopx.Object("Birthday-CD-Flame-BG").visible = False
    Select Case Mode
        Case "Mini"
      desktopx.object("Birthday-CD-LargeBG").visible = False
        desktopx.object("Birthday-CD-MiniBG").visible = True
        FT = 48 : FL = 193
        Call SetINIValue("Mode","Mini")
        Case "Large"
        desktopx.object("Birthday-CD-MiniBG").visible = False
      desktopx.object("Birthday-CD-LargeBG").visible = True
        FT = 74 : FL = 204
      Call SetINIValue("Mode","Large")
    End Select
  desktopx.Object("Birthday-CD-Flame-BG").top = FT
  desktopx.Object("Birthday-CD-Flame-BG").left = FL
  desktopx.Object("Birthday-CD-Flame-BG").visible = True
End Function
[/code]

You will see i make the flames visibility= false before i move it, then i swap the backgrounds, then i make it visible again.
This way you dont see it "move".

Again, this is the main reason for using "Functions", I didnt have to modify the code where i Call the Mode, and i can still go in and add even more functionality to the swap at a later time (fades, etc).

As i stated in the previous tutorial we needed to make the day/month work for international users not just USA.  To do this i went looking and found a function that the TRUE DX master VAD_M created called FormatDate.

This is an awesome function because you can pass it a date in m/d/y and it will format it in the locale's format.
Here is the function:

[code="vbscript"]
'---- FIX DATE FOR ANY LOCATION
Function FormatDate(xdate)
    On Error Resume Next
  Dim xd,s1,s2,sx
     If instr(xdate,"/") > 0 Then
      s1 = "/"
     ElseIf instr(xdate,".") > 0 Then
      s1 = "."
     ElseIf instr(xdate,"-") > 0 Then
      s1 = "-"
     End If
     Set objShell = CreateObject("WScript.Shell")
  xd = objShell.RegRead("HKEY_CURRENT_USER\Control Panel\International\sShortDate")
  s2 = objShell.RegRead("HKEY_CURRENT_USER\Control Panel\International\sDate")
     Set objShell = nothing
  sx = split(xdate,s1)
  If left(LCase(xd),1) = "d" Then xd = sx(1)&s2&sx(0)&s2&sx(2) Else xd = sx(0)&s2&sx(1)&s2&sx(2)
  FormatDate = FormatDateTime(xd,2)
     Set xd = nothing
     Set s1 = nothing
     Set s2 = nothing
     Set sx = nothing
End Function
[/code]

Then we have to make a few changes to the GetBDay Function to CALL this new Function.

[code="vbscript"]
Function GetBDay()
  BdayToday = False
  testDate = FormatDate(BMonth &"/" & BDay &"/" & year(now))
  CheckDate = IsDate(testDate)
  If CheckDate <> True Then
   Msgbox "Date: " & testDate & vbnewline & "is Invalid" & vbnewline & "Please select a new date"
   Call PrefsMenu()
  Else
        s = DateDiff("s", Now, testdate)
        If s > 0 Then
            BDate = cdate(testdate)
        Else
          testDate = FormatDate(BMonth &"/" & BDay &"/" & (year(now)+1))
            BDate = cdate(testdate)
      End If
      d = DateDiff("d", Now, testdate)
      If d= 365 Then        msgbox "HAPPY BIRTHDAY!!"
      desktopx.Object("Birthday-CD-Mini-BDate").text = BDate
  End If
End Function
[/code]

IE:

testDate = FormatDate(BMonth &"/" & BDay &"/" & year(now))

This seems to have fixed the problem with the d/m/y vs  m/d/y formats.

So now i have had a few people test it and it seems to be working.
It is saving the day/month/mode just fine, and seems to be doing the countdown.

The next hurdle is to make this do "something" special on the actual birthday.
I need input here, what should it do?

Play "Happy Birthday" or some other mp3 file?
Change the image to someone new?
What else?

PLEASE post and let me know what you think it should do.

RomanDA

2 Replies Reply 3 Referrals

Making your own countdown clock

Oct 29, 2008 5:08 PM by Discussion: DesktopX Tutorials

This is the first Tutorial I have done in a while.  I have been working, sick, busy, and to tired to do much of anything for a while.

I am working on a Coundown Clock for the BIRTHDAY community project and I want this to be a multiple part Tutorial on how to make your own.  The First thing we need to do is be able to figure out the Days, Hours, Mins, Seconds between now and Midnight on such-and-such date.  For this example we will use a REALLY important date in DX history... MY BIRTHDAY!!!

  1. Create a NEW Object in DX (see the multitude of other tutorials on this)
  2. Make it a "TEXT" object, and put in something in the text field, so that it shows on your desktop.
  3. Add a NEW Script to this object.
  4. copy/paste the code below into the new object.

[code="vbscript"]
Dim BDate

'Called when the script is executed

Sub Object_OnScriptEnter
 BDate = cdate("11/20/2008")
 object.text = "Calculating"
 Object.SetTimer 1, 1000
End Sub

Sub Object_OnTimer1
  CurTime = formatdatetime(now,3)
 object.text = "Date: " & formatdatetime(date,1) & vbnewline
 object.text = object.text & "BDate: " & formatdatetime(BDate,1) & vbnewline
 object.text = object.text & "Time: " & CurTime
     i = DateDiff("s", Now, BDate)
  DaysLeft = i \ 86400
  i = i Mod 86400
  HoursLeft = i \ 3600
  i = i Mod 3600
  MinutesLeft = i \ 60
  i = i Mod 60
  SecondsLeft = i
  If len(HoursLeft) < 2 Then HoursLeft = "0" & HoursLeft
  If len(MinutesLeft) < 2 Then MinutesLeft = "0" & MinutesLeft
  If len(SecondsLeft) < 2 Then SecondsLeft = "0" & SecondsLeft
  object.text = object.text & vbnewline & "Days: " & DaysLeft
  object.text = object.text & vbnewline & "Hours: " & HoursLeft
  object.text = object.text & vbnewline & "Mins: " & MinutesLeft
  object.text = object.text & vbnewline & "Secs: " & SecondsLeft
End Sub

'Called when the script is terminated
Sub Object_OnScriptExit
 object.KillTimer 1
End Sub

[/code]

Lets break down the above code.

  • Dim BDate
    This holds a space in the system for BDate so it can be setup in one part of the code and called from another
  • Sub Object_OnScriptEnter
    Runs when the object is loaded

  • BDate = cdate("11/20/2008")
    Sets the Birthday Date to 11/20/2008, you can put in ANY date for now. 
    it needs to be in your "local" format i believe.

  • object.text = "Calculating"
    Default Text to show

  • Object.SetTimer 1, 1000
    This turns on a timer called 1000 and runs what's in there every 1,000 milliseconds or 1 second

  • End Sub
    Ends the OnScriptEnter prrocedure

  • Sub Object_OnTimer1
    This is the Timer we started above, notice the 1 is the same as the 1, in our SetTimer call

  • CurTime = formatdatetime(now,3)
    Sets the Var CurTime to the Current Date in a format that shows hh:mm:ss a/pm

  • object.text = "Date: " & formatdatetime(date,1) & vbnewline
    Sets the Object's text to show the current Date as DayOfWeek, montname, Day, Year

  • object.text = object.text & "BDate: " & formatdatetime(BDate,1) & vbnewline
    Sets the Object's text to show the Birth Date as DayOfWeek, montname, Day, Year
  • object.text = object.text & "Time: " & CurTime
    Shows the Current Time
  • i = DateDiff("s", Now, BDate)
    Set the var i to the difference between NOW and the Birthdate in Seconds
  • DaysLeft = i \ 86400
    Sets the Var DaysLeft the difference between the dates (in seconds) to days
    86400 = 60 seconds * 60 mins * 24 hours
  • i = i Mod 86400
    Sets I down those same seconds into days
  • HoursLeft = i \ 3600
  • i = i Mod 3600
    Makes HoursLeft & I into Hours by deviding it by 3600 (60 seconds * 60 mins)
  • MinutesLeft = i \ 60
    i = i Mod 60
    Makes MinutesLeft & i into Mins by dividing it by 60 (seconds in a min)
  • SecondsLeft = i
    Simple enough I = the seconds left from all that dividing
  • If len(HoursLeft) < 2 Then HoursLeft = "0" & HoursLeft
  • If len(MinutesLeft) < 2 Then MinutesLeft = "0" & MinutesLeft
  • If len(SecondsLeft) < 2 Then SecondsLeft = "0" & SecondsLeft
    If the length of the # is less then 2 characters add the 0 to the begining so it shows 08, 07, 06 etc. no 8 7 6
    Just like it that way, your call
  • object.text = object.text & vbnewline & "Days: " & DaysLeft
  • object.text = object.text & vbnewline & "Hours: " & HoursLeft
  • object.text = object.text & vbnewline & "Mins: " & MinutesLeft
  • object.text = object.text & vbnewline & "Secs: " & SecondsLeft
    Sets the Object's Text to show Days/Hours/mins/Seconds in a row
    the vbnewline is just a linefeed to move the text to the next line
  • object.KillTimer 1
    Turns off the timer when the object closes

When you run the above you should see something that looks like:

Date: Wednesday, October 29, 2008
BDate: Thursday, November 20, 2008
Time: 1:07:36 PM
Days: 21
Hours: 10
Mins: 52
Secs: 24

This is just part 1, I will add more as i move on in making this new countdown gadget.

Hope someone makes use out of this.

RomanDA

 

 

 

 

8 Replies Reply 11 Referrals

ADVANCED BITMAP SETTINGS

May 27, 2008 9:46 PM by Discussion: DesktopX Tutorials
Step-by-Step Tutorials

#12 - ADVANCED BITMAP SETTINGS

A series by RomanDA

Listing of other DX Tutorials: Click here
Today's Lesson: "ADVANCED BITMAP SETTINGS"
will show you how to make use this section of DX.

The ADVANCED BITMAP SETTINGS allows you to stretch, or tile an image. This allows you to take a simple rounded corner background (or any background) and make it stretch to fit the size you want to use, without losing the aspect ratio of the image.

Typically this is used when you have a background (or any image) that you want to make wider or taller than it was origionally created for. 

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

Please look over the other tutorials to see how to load DesktopX, and also how to create a NEW object.

STEP 2 - Create an object

RIGHT CLICK on the icon in your system tray and create a NEW OBJECT.
The image im going to use for this tutorial is this one:

tut12-backimg

This is just a simple rounded corner box.

It's 100 pixels wide by 103 tall

The height diff is from the overhang of the little top yellow square.

PhotobucketGoto the STATES tab and BROWSE to the image above (or the one you want to test with).

APPLY this so you can see what it looks like on the screen.

It should look like the image on the right, its just a square.

 

STEP 3 - Stretching things out.


I want to show what happens with you simply change the height and width of the object without using the advanced bitmap settings.

Edit the object. goto the SUMMARY tab, and choose the height or width to see how it changes the box.

Stretch the Height to 200

Photobucket

Stretch the width to 200

back-str-width

You can see that the nice round box gets "stretched" out to match the height/width we used.
This is the problem, we want to KEEP the nice round shape, so we want to use the Advnaced Bitmap settings to setup margins that will keep our shape and "stretch" the inside of the area.

STEP 4 - Advanced Bitmap Settings

Edit the object again, and set the WIDTH to 200 and the Height to (image default).

Now go to the STATES tab and click on the ADVANCE button under the image information area.

I know how my background was created so i know that i should make the left/right margins both 30 pixels.  This sets up an area around the object.

margin settings 

I hope the image to the left gives you a good idea of what the margins are and how they are used to select a "section" of the image to KEEP and a section to either STRETCH or TILE.

Notice that when you pick left/right/top & bottom margins, you end up really picking just the corners.

This allows us to easily make the bg bigger without losing any of the basic layout and look of the object.

Origional set to 200pix wide:

back-str-width

Set the Width to 200 and then in the ADVANCED Tab use Left/Right to 30 and it looks like:  (notice that the LEFT and RIGHT sides are the same as the origional image, and the section between these is "stretched" out to fit the 200 pixel width.  Notice how the corners are nice and rounded? not stretched out.

Photobucket

Here is what happens if we make the margins a little to big since 55+55 is 110 its actually using 5 pixels on each side that doesnt even exist.  You might have to experiment a ltitle with your oen image to get the margins 100% correct.

Photobucket

Here is the Height BEFORE Setting the TOP/BOTTOM margins:

Photobucket

Now lets set the TOP/BOTTOM Margins to a little diff than LEFT/RIGHT and see how this looks:
I set them to 35x35 so that it picks up a little more of the margins.  you can experiment to see how it ends up looking.

Photobucket

CONCLUSION
Thats the basics.  There are some things you can do with TILE vs STRETCH.
That would depend on how your background image was created.  But i hope this at least gives you a little insite into how to use the ADVANCED BITMAP SETTINGS.
 
Enjoy,
RomanDA
AKA: David A. Roman
http://romanda.wincustomize.com
10 Replies Reply 7 Referrals
I have a few things that i am having some issues with, and im not sure if these are things that SD would have to add to DX or there is a way to do this in scripting.

[size="4"][B]Standard Preferences (Z-ORDER):[/B][/size]
Is there a way to set/change Z-Order of the entire widget from a script?
I am not a fan of the "standard properties" box, I like it better to have my own setup.
I would like to be able to set the Z-Order to "Always on top" then back to "Normal Level" from a script.

[size="4"][B]About Dialog Box:[/B][/size]
Is there a way to pull the VERSION from this dialog box? It has to be out there somewhere, its the version info we put into the gadget/widget when we export it.
Heck, why not ALL the info... something like.
widget.about.version
widget.about.author

That possible? Or does it exist somewhere.
Thanks in advance for any help.

(ok, now Vad, Tiggz are gonna come in here and make me look like a moron cause all this is out there somewhere, and i just dont know how to find it, but i can live with that, hell if Zu can make widgets, even I can learn.)

16 Replies Reply 7 Referrals

Jan 18, 2008 1:44 AM by Discussion: DesktopX

Hey all,

I'm sure most of you think i have given up on DX. Its been months since I posted anything on DX scripting, or creation. Just been working my butt of out-of-town for most of the past 4 months.
Actually I'm sitting in a hotel room right now.  Anyway, I was looking at something the other day and wondered how many little SIMPLE tricks are hidden in DX. I was talking to miksama the other day and he pointed sent me some cool things.

I wanted to share some things that not everyone might know about, or even use. If you know one of these and have been using it forever, goodie, show us something you think we dont know about. I want this it be an ongoing article with lots of user input.

These will require that you know at lease some basics of scripting in DX. If you don't you might want to do a simple Google search for DesktopX Tutorials, I hear SOMEONE spent a great deal of time on some.

Lets get this started with a few 1 liners.

PING:
You want to ping a web site and get the resulting time to site.

x = system.Ping("www.wincustomize.com")
object.text = x & " ms"

WALLPAPER:
Want to change your wallpaper?
This is the quick way to do it.

Option:
0 = use default wallpaper
1 = Center wallpaper
2 = Tile wallpaper
3 = Stretch wallpaper

'Examples:

System.SetWallpaper "C:\temp\wall1.bmp", 1
'Sets the wallpaper to the bmp above and the 1 makes it centered.

System.SetWallpaper Object.Directory & "wall1.jpg", 2
'Sets the wallpaper to wall1 in the directory where the dx object was created, and the 2 tiles it.

System.SetWallpaper "", 0 
'This will restore the original wallpaper.

CLIPBOARD:
Say you want to dump something from DX to the windows clipboard?
Its 1 line of code easy.
I believe this works only with TEXT, not images, but i could be wrong.

System.Clipboard = Object.text

VOLUME/MUTE:
Ok, want a fast way to set your volume to 10? or 90? or mute it completely?

system.Volume = 10
system.Volume = 90

'or mute it
system.mute

READ A FILE
Want to dump the contents of a file to a text string?
Only param=1 is currently supported.

txtLog = System.SimpleRead("C:\temp\file2read.txt", 1)

WRITE TO A FILE
Ok, this is simple, dump the contents of a string into a file.
Only param=1 is currently supported.

txtstring = "This is the text string, could have anything in here" & vbnewline & "even on a second line"
System.SimpleWrite "C:\temp\output.txt", txtstring, 1

These are just a few simple SYSTEM tricks. What do you have up your DX sleeve?

20 Replies Reply 151 Referrals

Animation Station

Jun 6, 2007 11:31 PM by 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
5 Replies Reply 20 Referrals

Hide & Seek

May 31, 2007 8:36 PM by 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
20 Replies Reply 19 Referrals

last tutorial?

May 28, 2007 1:07 AM by Discussion: DesktopX
Hey all,

I have been working out of town for what seems like a year now, but i hope to be in town for the next few days.

I have been working on these DX Tutorials for a while now, my original goal was to create 10, well, i have made 9 so far and only plan on doing 1 more (for now). The question of the day is, what would you aspiring DX coders want me to do this last tutorial on?

The plan was to do it on a INI type file, how to read/write data as well as show how to edit this info in a dialog box. But I want to make this something that people will actually want. I have had so little response on the last 3-4 tutorials, and would like this one to not end up like those.

So I will ask you.. but i need to know ASAP, so post some suggestions, the one i like the most (or gets the most comments) will win (if i know how to do it.. LOL), but i need to know by wednesday at the latest, so i can get it done before im shipped out of town AGAIN.

I really hope that someone has got some usage out of the previous tutorials.
29 Replies Reply 9 Referrals

Wallpaper Changer

May 2, 2007 2:13 PM by 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
15 Replies Reply 104 Referrals

May 1, 2007 4:30 PM by Discussion: WinCustomize Site Issues
Ok,

I tried this before to see how it worked, and it didnt.

Sample DX code: (copy/pasted from DX to here)

[code="vbscript"]
Sub Object_OnMouseEnter
Call ShowToolTip("This is my Tool-Tip","Info")
End Sub

Sub Object_OnMouseLeave
Call HideToolTip()
End Sub
[/code]

4 Replies Reply 5 Referrals

Tool-Tip Replacement

Apr 30, 2007 6:15 PM by 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
15 Replies Reply 25 Referrals

Woot!

Apr 23, 2007 6:50 PM by Discussion: Community


Hey all.. THANKS!!!

Its taken like 4 years, but when 80% of your gallery is DX widgets its hard to hit these kinds of numbers.

Thanks to all who have downloaded and supported my skinning and programming.
6 Replies Reply 2 Referrals

User Input / Save / Retrieve

Apr 11, 2007 3:14 PM by 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
2 Replies Reply 11 Referrals

Using WMI

Apr 5, 2007 1:06 PM by 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
15 Replies Reply 19 Referrals
Hey all,

I finished 5 of the "Step-by-step" DX tutorials and was wanting to continue the series (if people want me to), but i need to know what you would be looking for next?


Look over: Tutorial Listing

Let me know what you think would be a good next 4-5 steps???

these were some ideas before:
1. Start small: A "Hello World" widget... Basically, just a widget that says (in text and/or graphics, "Hello World"). -- DONE
2. Next, a widget with a little interactivity: Two or three buttons that you can click to make a message window appear. --- DONE
3. How to incorporate coding/scripting into the widget, so it can do more complex things. -- DONE
4. How to store settings, such as configuration settings and user input.
5. How to retrieve info from your computer (system settings, resources, etc.)
6. How to retrieve info from internet sources.
7. How to interact with Windows and programs (e.g., Outlook).

my goal is 10 step-by-step ones, but i dont want to repeat anything i have done.
11 Replies Reply 11 Referrals

Mar 24, 2007 8:43 PM by Discussion: Skinning
I know this has been going around here as far as DX being "skinned".

I have begun working on a widget that will be able to change based on the WB skin you are running. I have the code i need to make this work as far as finding the info... but its KNOWING the right info im looking for, THAT is the hard part.

The idea (for this one) is to make a "FRAME" that would pull the info from the current WB skin.

Please understand i know DX, NOT WB, I have never skinned anything in WB, so im asking q's of those who know the UIS file format.

The "FRAME" would be made up of multiple images, look below.



The INFO I need is:
TOP Image Left Margin (TLM)
TOP Image Right Margin (TRM)
Top Height (TH)

Left/Right Top/Bot Margins: LTM/LBM (same for right side)
Left right WIDTH as well.

Bottom Left/Right Margins BLM/BRM - Bottom Height

Also would need to know how to figure out what kind of BG (Background image) to use, image, or some color?

What I need is to know what "KEY" in the UIS file points to these items.

IE: TLM = TopTopHeight
TRM = TopBotHeight

If those are correct. I think this could really be kind of cool if it can be worked out. But since i know zippo about WB, im hoping one of you WB MASTERS will help me.

Is there anything else that we might be able to use? Buttons would be good to. I love it idea of making the widget look like a normal window, skinned of course. But if you have other ideas on how to do that to, please let me know. Lets make this a great community project!!

Thanks in advance!
RomanDA
34 Replies Reply 17 Referrals

Mar 14, 2007 8:35 PM by Discussion: Widget talk
I know we have had discussions on new Gallery's but I really think we need these 2.

1. DX Gadgets - this would be for gadgets only, so people without DX could load these and know they would work, and people with DX would know that everything in the WIDGET Gallery is a widget that can be imported.

2. DX Weather/Clock - yes yes yes, anyone that has ever been in the DX Widgets gallery know that there and have done a "search" for "weather" will return you 7 pages of 32 widgets, or MORE. This is just weather, not to mention clocks. The problem is, these are almost all (not all Vad_M/Martin/Richard) the SAME widget, just with different "skins". Its getting old. you post something that you have spent a great deal of time working on, and in 2 days, its on page 3, behind 200 more of the SAME weather widgets.

If you agree, or disagree, please let us know. I think these could easily be added and would make things so much better. If DX is going to EVER evolve beyond a weather/clock widget maker, it has to be able to SHOW what is out there that ISNT one of these.

PLEASE PLEASE HEAR US!!!
119 Replies Reply 11 Referrals

Replacing the RIGHT-CLICK menu! - Advanced Scripting

Mar 1, 2007 5:49 PM by Discussion: DesktopX Tutorials
Script Tutorials

#7 - Replacing the Right-Click Menu

A series by RomanDA

Listing of other DX Tutorials: Click here
Today's Lesson: "Replacing the Right-Click Menu"

This lesson is more advanced then the previous ones I have posted.
This is something that I have found myself working on a LOT lately.   Replacing the standard right-click menu that DX puts on everything with my own menu.  There are lots of reasons for this.

  • You want to remove the DX About box
  • You want to add more functions to this menu
  • You just don't like the standard menu, whatever...
  • You want to hide the standard preferences box
  • If you make it with PRO, you dont want the "CREATED WITH DESKTOPX PRO" on the about box!!

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.

---- UPDATE - REVISED THE CODE and uploaded this as a widget for you to download and enjoy HERE

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 - RegisterController
In order for DX to ignore the built-in right-click menu, you have to work a little magic.
Its not that complex, but it has to be setup in order to work.
  • Create a new object (see Tutorial #1)
  • Make it whatever you want, image/text.
  • Add the following to the script
  'Place this at the TOP of your code.
Dim IsMinimized
'We will use this to determine if the widget is minimized or not.
Dim ShowMenu  'Used to decide if we need to show/not show the right click menu

Sub Object_OnScriptEnter
  IsMinimized = False
'Set the IsMinimized to False
 
ShowMenu = False  'Use to set the right-click menu NOT to show
  desktopx.RegisterController Object.Name
'this code sets this object as the control for handling the right-clicks, etc.  The ides is to use the script into the MAIN object, and never add this in more then 1 place!!  It will mess things up.
End Sub
 
STEP 2 - OnControl Function
The OnControl function handles clicks on the tray icon, as well as right clicks coming from your widget.
  • Add the code below to the above script.
  Function OnControl(lType, lCode)
  OnControl = True
'Allow control to run
  ShowMenu = True
'Show the menu - by default
 
'These codes are there to allow you to use the RIGHT-CLICK from the tray icon, as well as the RIGHT-CLICK from the widget.
 
If lType=2 And lCode=517 Then ShowMenu = True ' RIGHT CLICK ON TRAY ICON
  If lType=1 And lCode=2 Then ShowMenu = True
' RIGHT CLICK ON ITEM

  If ShowMenu = True Then ' If we right-clicked on the tray or widget then...
  OnControl = True
'allow control to pass to the object
  If IsMinimized = False Then
'If the object isnt minimized (we will set this later in the popup menu) run the main popupmenu / else run the minimize popupmenu minimized function.
    Call PopupMenu
  Else
    Call PopupMenuTray
  End If
 End If
End Function

 
STEP 3 - Adding the POPUP Menu
The popup menu is the menu you want to show up when you RIGHT-CLICK on the widget/tray when the widget is not minimized, etc. (We will do the minimized version in a min).

I am not going to rip this all apart, there is another tutorial out there on making a right-click menu

  Function PopupMenu()
  Set mainmenu = nothing
  Set mainmenu = DesktopX.CreatePopupMenu
'-- Create Main Men
  If widget.Autorun=False Then
    mainmenu.AppendMenu 0, 1, "Autorun OFF"
  Else
    mainmenu.AppendMenu &H00000008, 1, "Autorun ON"
  End If
  mainmenu.AppendMenu 0, 2, "Minimize to Tray"
  mainmenu.AppendMenu 0, 3, "Close"
  mainmenu.AppendMenu &H00000800, 100, "seperator"
  mainmenu.AppendMenu 0, 4, "Preference"
  mainmenu.AppendMenu 0, 5, "About"

  '-- Save the results of mouse movements
  result = mainmenu.TrackPopupMenu(0, System.CursorX, System.CursorY)
  Select Case result
    Case 1
      If widget.Autorun = False Then
        widget.Autorun = True
      Else
        widget.Autorun = False
      End If
    Case 2
      IsMinimized = True
      object.Visible = False
    Case 3
      widget.Close
    Case 4
      widget.OpenProperties
    Case 5
      msgbox "This is my about box"
  End Select
End Function

 
STEP 4 - Minimized (Tray icon) menu
We are going to add a minimized menu, so that we have a way to restore the widget back to working order from minimized state.  Its not going to have all the functions of the main popup menu.

This menu will only be accessible with its minimized and from the tray icon.

  Function PopupMenuTray()
  Set mainmenu = nothing
  Set mainmenu = DesktopX.CreatePopupMenu
'-- Create Main Menu
  mainmenu.AppendMenu 0, 1, "Restore from Tray"
  mainmenu.AppendMenu 0, 2, "Close"
  '-- Save the results of mouse movements
  result = mainmenu.TrackPopupMenu(0, System.CursorX, System.CursorY)
  Select Case result
    Case 1
      IsMinimized = False
      object.Visible = True
    Case 2
    widget.Close
  End Select
End Function
 
STEP 5 - Add Left-Click menu
If you want you can also make the popup menu show when you LEFT-CLICK on the object as well.
This is a simple bit of code to be added to the object.
  Function Object_OnLButtonUp(x,y,dragged)
  If dragged = False Then
   Call PopupMenu
  End If
End Function
 

CONCLUSION

This should all work, there are a lot of options in the ONCONTROL function, as far as clicking works, this shuts off the CLICK HIDE/CLICK RESTORE on the tray icon as well, it has a way of messing things up.

This is not something i would recommend someone doing unless you really know DX.

One side effect of this is that you cant right-click on the main object anymore, it wont work, you will just get your menu (when editing things!!).  AND you will not be able to right-click the DX TRAY icon to pick edit, etc.  So just a warning.

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
9 Replies Reply 14 Referrals

Tutorial #4 - Scripting 101

Feb 25, 2007 6:42 PM by Discussion: DesktopX Tutorials
Step-by-Step Tutorials

#4 - Scripting 101

A series by RomanDA

Listing of other DX Tutorials: Click here

Today's Lesson: "Scripting 101"  - UPDATED 5/08/07

Today we will learn how to do some VERY basic scripting in DexktopX. Scripting in DX can be done with JavaScript as well as VBScript, but since i know next to nothing about Javascript, I will be covering VBScript.

Please Look over the previous 3 tutorials so that we can skip up to some things here without redoing everything we have already done. Things like Creating a new object, and changing font sizes, etc. I will not cover those again, if you haven't look at the first 3 you will need to go back and check them now.

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 object


Like I stated above, I am not going to walk you thru everything here, so please look over the other tutorials first.
  • Create a new object (see Tutorial #1)
  • Make it a TEXT object.
  • Make the text large enough you can see it on your desktop
  • Add the text DATE: to the object. (you can make it whatever color you want, and font)
  • RIGHT-CLICK on the new object and select PROPERTIES
STEP 2 - Making your first Script

  • From the PROPERTIES window click on the NEW Button, next to SCRIPT.
  • You will see the above screen (DX always creates a OnScriptEnter and OnScriptExit subs.
  • The ENTER is what runs when you load up the object for the first time.
  • The EXIT is what runs when you close down your object.
  • In this case we are going to make the object show the current date when we load it up
  • We are going to add a single line of code in the OnScriptEnter Section:
    • object.text = date
    • As you type in this info you will see dropdowns that show the options you can use.

       All you need to do is click on T in TEXT and this dialog will show up, so you can hit enter as soon as the dropdown jumps to Text, or continue typing.
  • That's it, lets cover what we just did.
    • object. - this is how DX refers to the current object, so that it knows what object we are working on.
    • text - this is the actual text of the object.
    • = - is simply telling it that the text EQUALS what comes next
    • date - the date is a built in function of visual basic. It is simply they current date.
    • combining it all, it takes the current object's text and makes it equal to the current date.
  • Once this is all entered, click on FILE then SAVE AND CLOSE Editor
  • Then click on OK and your TEXT on the desktop should show:
    (ok, it will show the REAL date, not the date I made this - lol)
STEP 3 - Adding some more info to the script

Hopefully the above wasn't to confusing, it worked, and your ready to add a little more to it.

  • RIGHT-CLICK on the the object and in the menu you will now have a few different options
  • You will want to click on EDIT SCRIPT
  • You should see the same EDIT window you saw above.
  • Let's add some text to the item.
  • edit the line object.text = date
  • to look like: object.text = "Date: " & date
  • What this does is put the text Date: before the date itself. the & is used to join the 2 items.
  • click on FILE then SAVE AND CLOSE Editor
  • Then click on OK and your TEXT on the desktop should show:
STEP 4 - Lets add some TIME

We are going to make this into a time object, with the current time being displayed at all times. To do this we need to add a TIMER to the object. Timers are just what they sound like, they perform an action at set intervals. You can have multiple timers running at the same time, they can be at different intervals. Lets see how this looks in the code:

  • RIGHT-CLICK on the object and select EDIT SCRIPT
  • We need to move some things around, please copy/paste the below code into your object.
  • Note the yellow text is only Comments, that's why they have a ' before them.
'Called when the script is executed
Sub Object_OnScriptEnter
  Object.SetTimer 1, 1000

  '-- This turns on a timer called 1000 and runs what's in there every 1,000 milliseconds or 1 second

End Sub

Sub Object_OnTimer1
'-- This is the Timer we started above, notice the 1 is the same as the 1, in our SetTimer call? '--- FormatDateTime(now,3) returns the complete time in the format: hh:mm:ss am/pm
 CurTime = formatdatetime(now,3)
 object.text = "Date: " & date & vbnewline & "Time: " & CurTime

'The vbnewline is a linefeed/break putting the time on a line UNDER the date

End Sub

'Called when the script is terminated
Sub Object_OnScriptExit
 object.KillTimer 1
'--- This shuts the timer off when the widget closes
End Sub

  • click on FILE then SAVE AND CLOSE Editor
  • Then click on OK and your TEXT on the desktop should show:
  • There will be a LAG of 1 second before this shows on the screen because it has to wait that 1 second before the Timer fires off. You can remove this lag by adding the following line right below the object.settimer line, so the Object_OnScriptEnter would look like this:
'Called when the script is executed
Sub Object_OnScriptEnter
 Object.SetTimer 1, 1000
 Call Object_OnTimer1
End Sub
 

Update for other Date Formats:


There are a lot of places in the world where the date isn't in the format mm/dd/yyyy.  To handle that, VAD_M has created a great function that will convert any date format to the current;y selected format of your system.

Lets show what our code looks like if we add VAD_M's code:

'--- NEW CODE or CHANGE

'Called when the script is executed
Sub Object_OnScriptEnter
  Object.SetTimer 1, 1000

  '-- This turns on a timer called 1000 and runs what's in there every 1,000 milliseconds or 1 second

End Sub

Sub Object_OnTimer1
'-- This is the Timer we started above, notice the 1 is the same as the 1, in our SetTimer call? '--- FormatDateTime(now,3) returns the complete time in the format: hh:mm:ss am/pm
 CurTime = formatdatetime(now,3)
 object.text = "Date: " &
FormatDate(date) & vbnewline & "Time: " & CurTime
'The vbnewline is a linefeed/break putting the time on a line UNDER the date

End Sub

'Called when the script is terminated
Sub Object_OnScriptExit
 object.KillTimer 1
'--- This shuts the timer off when the widget closes
End Sub

Function FormatDate(xdate)
  On Error Resume Next
  Dim xd,s1,s2,sx
  If instr(xdate,"/") > 0 Then
   s1 = "/"
  ElseIf instr(xdate,".") > 0 Then
   s1 = "."
  ElseIf instr(xdate,"-") > 0 Then
   s1 = "-"
  End If
  Set objShell = CreateObject("WScript.Shell")
  xd = objShell.RegRead("HKEY_CURRENT_USER\Control Panel\International\sShortDate")
  s2 = objShell.RegRead("HKEY_CURRENT_USER\Control Panel\International\sDate")
  Set objShell = nothing
  sx = split(xdate,s1)
  If left(LCase(xd),1) = "d" Then xd = sx(1)&s2&sx(0)&s2&sx(2) Else xd = sx(0)&s2&sx(1)&s2&sx(2)
  FormatDate = FormatDateTime(xd,2)
  Set xd = nothing
  Set s1 = nothing
  Set s2 = nothing
  Set sx = nothing
End Function

CONCLUSIONN


Ok, you now have a working date/time clock on your desktop now.. woo hoo.. LOL I hope this first step into scripting in DX has shown you how simple it can be. I will continue to work on scripts for the next 2-3 tutorials, mainly the basics, if you want more complicated Tutorials look over my older ones on the index page.

I know this is some very basic stuff, but that is the idea, most people are afraid of scripting, and I want to show that anyone can get in there and at least get started on scripting.

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
36 Replies Reply 28 Referrals

Feb 22, 2007 11:18 PM by Discussion: DesktopX Tutorials
Step-by-Step Tutorials

Tutorial Listing

A series by RomanDA

These Tutorials are designed to help anyone who wants to learn DesktopX. This page will be updated as I add more Tutorials, so WATCH this to see when its updated.

This current set of tutorials is complete. I hope you have enjoyed them. PLEASE post comments on the individual posts, not here, THANKS!

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

Other DesktopX Tutorials

Below is a list of the older tutorials I made (these are more advanced then the Step-By-Step ones above.

Enjoy,
RomanDA
AKA David A. Roman
http://romanda.wincustomize.com
16 Replies Reply 111 Referrals