DX Coders, lend me your ears!
Thursday, April 12, 2007 by sViz | Discussion: DesktopX
Sub Object_OnScriptEnter
End Sub
into system clipboard. So you basically click and paste. I'm always opening up multiple text files where I keep my scripts (or even opening up web pages) and highlighting, copying, pasting, and I thought it would be easier and less cluttered to have a convenient place to grab them from. At the moment all the information in the lists are formatted (rss style) and written to a text file in Local Settings > Temp. I will ultimately make it attached to the widget in the object directory. I can also add codes in the textfile itself and when I load up the widget the list will be compiled with the additional changes, creating a text object for each new item.
Here's where I need your input. There will be three lists. A custom list where you put the ones you've constructed, a standard list with all the basic DX sub procedures and funtions, and a resource list where you put links to tutorials on the web or a file on your computer.
I've already compiled as many codes as I can think of for the DX standard list but can you guys tell me if I've left any out? Also, what DX/scripting resources on the web do you think should be included with the widget?
Please look over the lists and let me know what I should add.
Here's the DX standard list:
OnScriptEnter
OnScriptExit
OnStateChange (can easily be modified to OnStateChanged)
OnMouseEnter
OnMouseLeave
OnShow
OnMove
OnSize
OnDropFiles
OnDrag
OnDragFinish
OnSetFocus
OnKillFocus
OnChar
OnKeyDown
OnLButtonDown
OnRButtonDown
OnLButtonUp
OnRButtonUp
OnLButtonUpEx
OnRButtonUpEx
OnScreenChange
OnWorkAreaChange
Pop Up Menu
DesktopX Form
Font Form (One setup specifically for font options and how to apply them to text objects. Will be asking Vad_M for permission.)
Dialog Box- files (for browsing)
Dialog Box- folders (for browsing)
Widget Preferences (including OnPreferencesChange)
For each elem (just as an enumeration example)
Select Case (I use this alot)
I didn't include any for the ActiveX controls as most come with script wizards but let me know if there are any you feel should be included.
Here's the resource list so far:
DX User's Guide online
DX tutorials on WC
Wincustomize DX forums
Stardock DX forums
Wincustomize
W3Schools VBScript Reference
MSDN VBScript Reference
Thanks.
Reply #3 Thursday, April 12, 2007 10:27 AM
(They'll be credited)Input boxes and message boxes, okay. You think I should put them in the OnLButtonUp procedure so the user can test them easily or in a separate sub like Sub mySub so they can be called from anywhere?
Reply #4 Thursday, April 12, 2007 10:48 AM
People can use the WMI Code Creator for WMI. Then again I still haven't wrapped my mind around it.
Reply #5 Thursday, April 12, 2007 11:09 AM
This sounds really good.
Maybe the RIGHT-CLICK REPLACEMENT stuff i wrote about a little while back, i use that alot. There seem to be a lot of things i use over and over.
What i end up doing is "importing" the widget that has X in it and copy/paste it out, then delete the widget etc. I do have some text files that have some standard code.
One thing i use a lot is the mouse click stuff. I think i need to get out of the habit of putting my code in every button/object, and keeping it all in 1 main object. VAD_M does that alot, and its really great coding wise. Its just not how i learned so i have to re-learn my brain to use this way. It would make changes a lot easier, as all the code would be in one location. Some of my items have code in 30 places. Thats not the best idea.
I think the community here is really pushing DX coding, its great. The DX SCRIPT MANUAL that Thomassen did is great, and this goes right into that as well.
I really hope that the tutorials are helping to being people into DX(ing).

Reply #6 Thursday, April 12, 2007 11:16 AM
Reply #7 Thursday, April 12, 2007 12:06 PM
Thanks for the link DA and the kick in the head; I forgot about your tut. Do you mind if I put some of your scripts into the widget? (with credit) The first part that pulls the computer name, domain name, and user name I think is enough to get a user started. Then maybe a link in the resources list to a good site about WMI.
Right click replacement, just read your tut. This seems like a handy piece of code to include. I'm going to need to include the codes from steps 1-4 if you don't mind?
I'm doing that alot now, too.
Reply #8 Thursday, April 12, 2007 12:19 PM
As for a common code, i need to see about making an external script file, i have never done that, can it be encoded as well? So no one can just take that file and see what it does? Does that code get complied into the Gadget or does it stay a separate file?
If it only exists on my machine, that could solve a LOT of these issues. Make one common file with all the functions in i normally use, then just append that into my code and I can then call all the functions/subs i want.

Reply #9 Thursday, April 12, 2007 12:41 PM
I've never used external scripts either. I only know what Brad wrote in his tutorial but that was almost a year ago and I don't know whether or not they worked all the issues of code protection out.
Reply #10 Thursday, April 12, 2007 1:01 PM
I found a free activeX that runs as service allowing you to access your vbscript functions from any app. Haven't downloaded & tested it but, definitely sounds great for enhancing desktopX IMO.
Just started doing this for vbscript files. It saves a lot of time being able to call functions with a line or two of code instead of having to re-write functions and sub's.
Reply #12 Thursday, April 12, 2007 1:31 PM
Reply #13 Thursday, April 12, 2007 4:19 PM
When you run the object.SetScript("script") it stops all further script processing in the object, and the only script to run in from the "Script" file.
What I tried (and worked) was to make an object called "RomanDAs_Functions" and added several functions in to it (using the WMI Tutorial I did) and then made an object to call these functions from the "RomanDAs_Functions" object. Its a little long on the code lines, but it works great.
The idea would be to have this one object with all your "common" functions in it, then just call them from the other objects you need to use them in.
Example (object RomanDA_Functions)
Function Get_PCName()
Get_PCName = ""
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set CompInfo = objWMIService.ExecQuery ("Select * from Win32_ComputerSystem")
For Each objComputer In CompInfo
PCName = objComputer.Name
Next
Get_PCName = PCName
End Function
Then in the text object where i want to pull the PCName i would use:
object.text = "ComputerName: " & desktopx.ScriptObject("RomanDA_Functions").Get_PCName & vbnewlineThis works really well. I also made a function to read the WMI's Hard Drive Info:
Dim Drive_Count, Drive_TotalSpace(100), Drive_FreeSpace(100), Drive_UsedSpace(100)
Dim Drive_FileSystem(100), Drive_Description(100), Drive_Type(100), Drive_VolumeName(100)
Dim Drive_Letter(100)
Sub GetDriveInfo()
Drive_Count = 0
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set DriveInfo = objWMIService.ExecQuery ("Select * from Win32_LogicalDisk")
For Each objDrive In DriveInfo
Drive_Count = Drive_Count + 1
Drive_Letter(Drive_Count) = objDrive.DeviceID
Drive_TotalSpace(Drive_Count) = objDrive.Size
If objDrive.Size > 1 Then
Drive_TotalSpace(Drive_Count) = FormatNumber((objDrive.Size/1048576),2)
end if
Drive_FreeSpace(Drive_Count) = objDrive.FreeSpace
If objDrive.FreeSpace > 1 Then
Drive_FreeSpace(Drive_Count) = FormatNumber((objDrive.FreeSpace/1048576),2)
end if
Drive_UsedSpace(Drive_Count) = objDrive.Size - objDrive.FreeSpace
If Drive_UsedSpace(Drive_Count) > 1 Then
Drive_UsedSpace(Drive_Count) = FormatNumber((Drive_UsedSpace(Drive_Count)/1048576),2)
end if
Drive_FileSystem(Drive_Count) = objDrive.FileSystem
Drive_Description(Drive_Count) = objDrive.Description
Drive_Type(Drive_Count) = objDrive.DriveType
Drive_VolumeName(Drive_Count) = objDrive.VolumeName
Next
End Sub
Then in the Text Object i would use a call like:
Call desktopx.ScriptObject("RomanDA_Functions").GetDriveInfo()
For x = 1 To desktopx.ScriptObject("RomanDA_Functions").Drive_Count
object.Text = object.Text & vbnewline &_
desktopx.ScriptObject("RomanDA_Functions").Drive_Letter(x) &_
vbnewline & " " &_
desktopx.ScriptObject("RomanDA_Functions").Drive_TotalSpace(x) & "KB" &_
vbnewline & " " &_
desktopx.ScriptObject("RomanDA_Functions").Drive_FreeSpace(x) & "KB" &_
vbnewline & " " &_
desktopx.ScriptObject("RomanDA_Functions").Drive_UsedSpace(x) & "KB" &_
vbnewline & " " &_
desktopx.ScriptObject("RomanDA_Functions").Drive_FileSystem(x) &_
vbnewline & " " &_
desktopx.ScriptObject("RomanDA_Functions").Drive_Description(x) &_
vbnewline & " " &_
desktopx.ScriptObject("RomanDA_Functions").Drive_Type(x) &_
vbnewline & " " &_
desktopx.ScriptObject("RomanDA_Functions").Drive_VolumeName(x)
NextThis is just one way to do things.
The goal would be to keep the "RomanDA_Functions" up-to-date with all your most used code.
You could make it point to an object that has 0 Visibility, and then it could be added to any project.
This also makes your code "compile" and encrypt into your EXE, so your code is avail, but protected.
Another way would be to have a function call in DX:
object.IncludeScript("C:\code\RomanDA_Functions.VB")
This would just LOAD into the current object the code from that VB file.
This could be a problem with compiling, encrypting, etc.
But the DX Programmers would need to add this function to DX.
Maybe we call all ask nicely? Maybe make it so that when it compiles an EXE it LOADS that code into the actual object and then encodes it there???
Just some alternatives.
Reply #14 Thursday, April 12, 2007 6:50 PM
Ah! Reading/writing text files. Seeing as how I'm doing that alot with this widget it should be useful. Yes, please send them, and thank you! Gotta go now.
If anyone else has some useful pieces of codes to lend, send 'em over via PM or email. (Don't forget to tell me what they are, though)
Reply #16 Friday, April 13, 2007 1:09 PM
You can include more than one script in your DX script using a custom include function.
For WMI, there is a very handy tool called Scriptomatic. Check it out for examples of how to access anything WMI has to offer.
Reply #17 Friday, April 13, 2007 1:21 PM
You can include more than one script in your DX script using a custom include function.
When you run the object.SetScript("script") it stops all further script processing in the object, and the only script to run in from the "Script" file.
Zubaz is confused
Reply #18 Friday, April 13, 2007 1:26 PM
How can you "INCLUDE" content with a "custom include function"??? Can we see a sample?
Reply #19 Friday, April 13, 2007 1:32 PM
The deal with object.SetScript is that it is a DesktopX function, from the DesktopX namespace. Its behavior is set, and it is such that it will allow essentially a single complete replacement script. This was a workaround to the fact that it is hard to save a backup from the DesktopX editor and every once in a while you are really glad you saved your script to an external file.
But for real, traditional 'Include' functionality we can use a custom function in the main script. This function works not as an extension of DesktopX, but rather a capability of vbscript itself, and does not replace, but inserts text.
Reply #20 Friday, April 13, 2007 1:37 PM
can you show me this line? Im not seeing it.
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, April 12, 2007 10:00 AM