DX Script Help!!!
Arrrg!
Monday, February 13, 2006 by brain21 | Discussion: DesktopX
So now I must try to accomplish the following:
1) Be able to write to a (local) file a new IP address. - EDIT:DONE!
2) Read in the file and put the contents EDIT:DONE! (but not the dropdown stuff) in a drop down (list) box (would this be done as an array?)
3) Be able to select that IP addr from the drop downbox (which would then set the value of that dropdown box's variable to the selected IP addr, which I guess would eliminate the need for an array, really)
4) Take the current variable value from the drop down box (the selected IP addr) and pass that to the commandline.
5) Get the output from the cmd.exe console and pipe it (hopefully) in realtime to a textwindow
6) Once finished, a Button on the object should kill the console box (cmd.exe)
I think step 4 should be simple enough. Something like:
objShell.run "telnet" & DesktopX.ScriptObject("IPAddr").SelectedIP & DesktopX.ScriptObject("port").SelectedPort, 0, True
to run comething like
telnet 127.0.0.1 25
(assuming the IP addr & port are in the seperate objects "IPAddr" and "port").
Basically I am trying to make something like this:
http://www.wap.org/journal/security3/portscansm.jpg
by using DX and the commandline.
END EDIT
OK, I need help. I am new to scripting w/ DX & VBScript, etc. I can't seem to get this to work...
I want an object with a drop-down box. The drop down box should have a list of IP addrs. I want an "Add host" button that I can click on, enter in an IP, and that IP is added to the list in the drop down box.
I then want another drop downbox that has various commands in it (say ping, netstat, etc. - commandline stuff).
My object is to CLick "add" and put in an ip addr which is then added to the dropdown box (lets say 10.1.1.1). I select an ip from the drop down box. Then in the next drop down box I select something like Ping. I click on the "Go" button.
In the background the app runs the command
ping 10.1.1.1
Then the output of this command is dumped to a textbox for display.
When I am done, I can then click on a "FINISHED!" button that will kill the process (the ping process), and then clear the display box.
Then if I wanted to run something like netstat I could select "None" from the dropdown list, and the command netstat and it would run
netstat -a
and dump the output to the textbox. Alternately I could not have the none, and just set it so that when I choose netstat from the command, it does not utilize the IP addr variable in the commandline at all.
If you are familiar with the MAC OSX network panel where you can fill in an IP and click on the ping or traceroute, etc. buttons and it shows you the results in the window, you have a really good idea of what I am trying to build.
If this requires writing to and reading from an .ini file of sorts, that is fine. I want to ultimately package this up as a DXPro Gadget so I can use it at home & at work, etc.
Any help with this would be greatly appreciated.
I have looked at a number of Objects & downloaded them. Either I am too clueless to figure it out, or something, cause nothing is really helping. If anyone can point me in the right direction I would be grateful. I am definitely a n00b, so a handholding site would be nice.
Yes, I looked through the DX scripting reference, etc. Didn't help.
I am stuck!

Thanks,
Brain21
Reply #2 Tuesday, February 14, 2006 11:29 AM
It seems that with a comboBox I can hard code things in the list, and then add things to the list as well. Am I correct in assuming that if I add something to the combo box it will remain in there even when the app is closed & reopened, but if I give the app to someone else, they will only get the hardcoded stuff in the list, and they will have to add whatever to the list? If so, this is fine (preferred actually).
Thanks!
Brain21
Reply #3 Tuesday, February 14, 2006 12:16 PM
Reply #4 Tuesday, February 14, 2006 12:55 PM
I tend to go direct to the registry for storage, but you can also take a look at Object.LocalStorage and Object.PersistStorage.
The combo box will not save data if you unload the object, but it will if you just make it invisible (Object.Visible=False). You will have to save it yourself if you want it to persist across unloading/loading.
If you use the registry, or Object.LocalStorage, the data will not persist beyond your machine.
You could simply define some contants for your default values, and use those to init the combobox data on a new install.
Reply #5 Tuesday, February 14, 2006 5:12 PM
I made sure on the properties that everything was visible. I can see the box itself, its just that it's empty. I played with the color scheme to make sure it wasn't something like black text on a black background with black highlighting. (BTW, is there an ole_color to RGB conversion tool out there? I am totally guess when putting in number values for the combobox properties).
I have set the default value of the box to "ping". I then added another object that when I click on it, it puts the current combolist value into a message box. Click on the button and I get "ping" in the MsgBox. Change the default value to something else (in the script), and the msgbox pops up something else. When I try to do anything with the dropdown, it's blank, and nothing changes the default value other than editing the script.
Anyone know what I am doing wrong?Another weird thing. I tried creating a completely seperate object (a button) that would create a form. I think something like
frm = DesktopX.CreateForm
and then I create the form just like a simple dropdown in terms of preferences, but slightly different...
frm.AddPreference "FormName"
frm.Preference("FormName").Type = "Text"
frm.Preference("FormName").DefaultValue = "ThisIsMyDefault"
something like that. So I click on the button. A form pops up. The text box is there, only instead of seeing "ThisIsMyDefault" in the box like I expect, I see "ping" WTF?!?!??!!? This object and the others are all named differently, and there is no child parent relationship between them at all or anything like that. Nowhere in my FormName script do I referr to the object/widget/preferences that has "ping" set to the default, yet SOMEHOW this object is getting "ping" as the default as if it were globally declared or something, and it's overriding what I have in the script! What's going on here? WHat am I doing wrong?
As far as persistent storage, I can write to a file and I'll figure out a way to read in the file and dyanmically add to the drop downlist a little later...
Oh yeah, I have had to recreate this several times because everytime I'm doing this I'll make some seemingly random change to the widget.preferences stuff, and when I click Apply & Save, DesktopX takes a big crap & dies. If I try to reload my current desktop, it tries to reload those objects, croaks, & dies again, so I have to constantly load w/ a blank desktop & start from scratch. Fun!
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 Monday, February 13, 2006 8:02 PM
ComboBoxes are described on pg. 54 of the DesktopX Scripting Guide PDF ( https://www.stardock.com/products/desktopx/docs/3x/DXScripting.pdf ). To set one up, create a new object, add a new script to it, then
Script->ActiveX Control->Select Control... -> DesktopXComboBox.
So, your step 4 sample might look more like:
objShell.run "telnet " & DesktopX.ScriptObject("MyIPComboBoxObj").Control.Text & " " & DesktopX.ScriptObject("MyPortComboBoxObj").Control.Text, 0, True
Hope that gets you started. I noticed the Mac sample image used buttons for each function, rather than the ComboBox / Go!-Button method you first described. That could make for easier programming too--ComboBoxes are handy, but resorting the lists, etc. can sometimes get tricky. Anyway, GL, have fun!