DesktopX Tips and Tricks
Thursday, January 17, 2008 by RomanDA | 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?
Reply #2 Thursday, January 17, 2008 9:23 PM
Repost:
I've been using object.comments to quickly store information on the fly without having to use persiststorage or localstorage.
I use it mostly for launching shortcuts especially when the target is dynamic and changes frequently. You get a path from user input, e.g. "c:\", you store it in, and launch it from object.comments.
- Object.comments = "c:\"
- 'Called when L-click is released
- Function Object_OnLButtonUp(x, y, dragged)
- If not dragged then
- On Error Resume Next
- Set Sh = CreateObject("WScript.Shell")
- Sh.Run (Chr(34)& object.comments & Chr(34))
- Set Sh = Nothing
- End If
- End Function
Excellent tips you've highlighted, by the way.
Reply #3 Thursday, January 17, 2008 9:32 PM
BTW, code doesnt work here.. in articles, its a pain.
Reply #4 Thursday, January 17, 2008 9:41 PM
Reply #5 Thursday, January 17, 2008 11:45 PM
My most favorite one recently is the ctrl+space code suggestions. Still haven't got all the properties items down pat.
Reply #6 Friday, January 18, 2008 5:59 AM
Thank you David
Reply #9 Saturday, January 19, 2008 11:06 PM
Also, I periodically copy the script into a txt file - not only can this be handy in dire emergencies (when dx explodes for no apparent reason), it is also extremely useful, maybe months later, when making something else to be able to quickly reference all your old scripts and graft parts into your latest project.
Reply #10 Sunday, January 20, 2008 6:26 PM
1. Object Margins
desktopx.object("some object").states("").setmargins left, top, right, bottom, stretch_X, stretch_Y
desktopx.object("some object").states("Mouse away").setmargins left, top, right, bottom, stretch_X, stretch_Y
2. Object Shadow (Glow)
desktopx.object("some object").states("").setshadow enabled, sharpness, darkness, offset X, offset Y, rgb(r,g,
desktopx.object("some object").states("Mouse away").setshadow enabled, sharpness, darkness, offset X, offset Y, rgb(r,g,
3. Object Font
desktopx.object("some object").states("").settont fontname, fontsize, bold, italic, underline, strikeout, charset
desktopx.object("some object").states("Mouse away").settont fontname, fontsize, bold, italic, underline, strikeout, charset
4. The easy way to download any file through internet
system.DownloadFile(URL, localPath, True)
Reply #11 Monday, January 21, 2008 8:12 AM
I think that if you are looking for windows INFO from your system that WMI is THE place to go. I am working on an update for my DROP INFO program that will have a lot more info.
Love it!! Keep 'em coming!
Reply #13 Tuesday, January 22, 2008 6:34 AM
I've been using loops alot more lately. In the following example I use a loop to incrementally reduce the number of letters in a text object so that it fits in a given width. Also contains an example of object.parentname to...yep, get the name of an object's parent.
- n = 0'add before the loop
- 'then inside your loop add the following lines
- n = n + 1
- if n > 100 then exit do'where 100 is a number that you think should be plenty ;)
- 'it could be 1000
p.s. you have to be quite careful when using loops to ensure that you don't create an endless loop that never exits. If you are unsure just add something like the following when testing your loop...
- n = 0'add before the loop
- 'then inside your loop add the following lines
- n = n + 1
- if n > 100 then exit do'where 100 is a number that you think should be plenty ;)
- 'it could be 1000
Remove this precautionary code when you're sure your loop is working as intended
Reply #14 Tuesday, January 22, 2008 6:36 AM
I've been using loops alot more lately. In the following example I use a loop to incrementally reduce the number of letters in a text object so that it fits in a given width. Also contains an example of object.parentname to...yep, get the name of an object's parent.
- t = object.text'assign the object's text to a variable
- Do'start of loop
- bTooLong = False'set the checking boolean
- If object.width > desktopx.Object(object.parentname).width Then
- bTooLong = True'reset boolean which will force the loop
- t = left(t,len(t)-1)'remove a character from end of text
- object.text = t & "..."'apply new text to the object, add dots for missing characters
- End If
- Loop While bTooLong'return to beginning of loop to recheck widths
p.s. you have to be quite careful when using loops to ensure that you don't create an endless loop that never exits. You can always increment a variable inside the loop, and exit the loop using "exit do" if the variable goes over, say, 1000
*edit* ignore the previous post - had some problems with the code tags etc (ironically enough)
Reply #15 Wednesday, January 23, 2008 8:35 PM
Say you want the widget/gadget to load a file from the directory its running from.
Well.. if your in BUILDER mode, the widgets executable folder is where DX Builder is running from, not where the widget's exe will end up. SO this could help when testing the program in builder mode, ie:
DesktopX.HostTypeReturns the host that is currently running the object. Return values are:
1 – DesktopX Client
2 – DesktopX Builder
3 – Widget runtime
4 – DesktopX PRO application
0 – Unknown
It could be used like this:
if DesktopX.HostType = 3 then
ExFolder = desktopx.ExecutableDirectory
else
ExFolder = "C:\temp\testfile.ini"
end if
Reply #16 Wednesday, January 23, 2008 11:34 PM
Reply #17 Thursday, January 24, 2008 6:35 AM
Reply #18 Sunday, March 9, 2008 7:16 PM
When the menu is called selecting that letter will execute the resulting menu item.
- mainmenu.AppendMenu 0, 1, "&item1"
- mainmenu.AppendMenu 0, 2, "i&tem2"
- mainmenu.AppendMenu 0, 3, "it&em3"
Reply #19 Sunday, March 9, 2008 7:44 PM
Please login to comment and/or vote for this skin.
Welcome Guest! Please take the time to register with us.
There are many great features available to you once you register, including:
- Richer content, access to many features that are disabled for guests like commenting on the forums and downloading skins.
- Access to a great community, with a massive database of many, many areas of interest.
- Access to contests & subscription offers like exclusive emails.
- It's simple, and FREE!
Reply #1 Thursday, January 17, 2008 9:14 PM