Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Combobox in windows script host ?

Reply
 
Old 07-08-2009   #1 (permalink)
Vilius Mockûnas


 
 

Combobox in windows script host ?

Hello,

Is it possible to use combobox functionality in wsh using vbscript ?

thanks
Vilius



My System SpecsSystem Spec
Old 07-08-2009   #2 (permalink)
mayayana


 
 

Re: Combobox in windows script host ?

> Is it possible to use combobox functionality in wsh using vbscript ?
Quote:

>
Yes. Your question isn't very specific. There's
no native GUI with WSH other than message
boxes. The typical way to create a GUI is with
HTAs/webpages running in IE. With IE 5/6 you
can make that look like anything you like. Starting
with IE7 you can't entirely remove the IE frame.
So without using a 3rd-party control you're limited.

If you mean using a dropdown list, and you
understand about using IE, then you can just use
a SELECT element with a SIZE attribute of 1.

To add items to the list you do something like this:

Set Opt = document.createElement("OPTION")
Opt.text = sItemText
Combo1.add Opt '-- where Combo1 is your SELECT.

-------------

See here for a sample custom message box for IE 5/6:

www.jsware.net/jsware/scripts.php5#msgb
screenshots:
www.jsware.net/jsware/msggal.php5

As you can see from that, the options are almost
unlimited using HTML, CSS and VBS for IE5/6. And one
of the samples includes a "combobox". But those
samples work by setting Fullscreen = True and then
specifiying a size for IE, so that only the actual browser
window shows, with no IE window frame. Microsoft
changed the functionality with IE7 so that you can't
do that anymore. And anything custom is likely to
becomes a morass of dysfunction if you're running
with the permissions complications of Vista/7.


My System SpecsSystem Spec
Old 07-08-2009   #3 (permalink)
T Lavedas


 
 

Re: Combobox in windows script host ?

On Jul 8, 3:41*am, "Vilius Mockûnas" <v_mocku...@xxxxxx> wrote:
Quote:

> Hello,
>
> Is it possible to use combobox functionality in wsh using vbscript ?
>
> thanks
> Vilius
As mayayana said, another application, such as IE, must be used to
display a GUI window. Here is a true Combobox example that uses IE as
its console window ...

' Combo box demonstration script
' Tom Lavedas, July 2009
'
' Start Main

Dim oIE, oDoc, oComboBox1, oShow, bClosing

set oIE = createObject("InternetExplorer.Application")
with oIE
' Configure the IE window
.RegisterAsDropTarget = False
' Remove the 'chrome'
.addressbar = False : .statusbar = False
.toolbar = False : .menubar = False
.resizable = False
' Size it
.width = 450: .height = 200
.Navigate "about:blank"
Do until .ReadyState = 4 : WScript.Sleep 100 : Loop
set oDoc = .document
.Visible = true
end with ' oIE

with oDoc
.open
.writeln "<html><head><title>ComboBox Example</title></head>"
.writeln "<body scroll=no>Make a selection or key new entry "
.writeln "and press Enter key ...<br><object "
.writeln "classid=clsid:8BD21D30-EC42-11CE-9E0D-00AA006002F3"
.writeln "id=ComboBox1 width=400></object><p>"
.writeln "<input type=button id=Show value=Show> "
.writeln "<input type=button id=Close value=Close><br>"
.writeln "<div id=Selections>&nbsp;</div></body></html>"
.close
Do until .ReadyState = "complete" : WScript.Sleep 100 : Loop
set oComboBox1 = .all.ComboBox1
set oShow = .all.Show
set oSelections = .all.Selections
end with

with oComboBox1
.List = Array("Black", "Blue", "Green", "Red")
.AutoWordSelect = true
.focus
end with
oDoc.parentWindow.opener = "Me"
set oDoc.all.Close.onclick = GetRef("Closing")
set oCombobox1.onblur = GetRef("Checkit")
set oShow.onclick = GetRef("showlist")
bClosing = false

on error resume next
do until bclosing: wsh.sleep 100 : loop
oIE.quit

' End Main

sub Closing : bClosing = True : end sub

Sub CheckIt
if len(oComboBox1.Value) > 0 Then
oSelections.insertadjacentHTML "afterbegin", oComboBox1.Value &
"<br>"
oComboBox1.AddItem oComboBox1.Value, 0
oComboBox1.Value = ""
oCombobox1.focus
end if
End Sub

Sub ShowList
Dim arr, i
Redim arr(oComboBox1.ListCount - 1)
for i = 0 to Ubound(arr)
arr(i) = oComboBox1.List(i)
next
msgbox Join(arr, vbnewline)
end sub

Tom Lavedas
***********
My System SpecsSystem Spec
Old 07-08-2009   #4 (permalink)
mayayana


 
 

Re: Combobox in windows script host ?

>
<object classid="clsid:8BD21D30-EC42-11CE-9E0D-00AA006002F3"
id="ComboBox1" width=400></object>
Quote:

>
It's hard to see how that's preferable to a SELECT
element. Doesn't SELECT pretty much look and act
the same way as a system combobox? And it also
avoids security issues with ActiveX or unsupported
systems. (I don't know what your object is:
8BD21D30-EC42-11CE-9E0D-00AA006002F3
It's not on my system.)

My System SpecsSystem Spec
Old 07-08-2009   #5 (permalink)
T Lavedas


 
 

Re: Combobox in windows script host ?

On Jul 8, 10:52*am, "mayayana" <mayaXXy...@xxxxxx> wrote:
Quote:

> <object classid="clsid:8BD21D30-EC42-11CE-9E0D-00AA006002F3"
> * * id="ComboBox1" width=400></object>
>
>
>
> * It's hard to see how that's preferable to a SELECT
> element. Doesn't SELECT pretty much look and act
> the same way as a system combobox? And it also
> avoids security issues with ActiveX or unsupported
> systems. (I don't know what your object is:
> *8BD21D30-EC42-11CE-9E0D-00AA006002F3
> It's not on my system.)
I was worried that that object was a later addition to the OS. I
suspect it came along with Win 2K or so. You are still using Win 98,
aren't you? It is part of the Windows Forms collection of objects
provided by a FM20.dll.

The main difference between the Combobox and Select is the ability to
key in items NOT contained in the existing list of items. That is, it
is a combination of Textbox and Select controls. It can be handy in
that the user input can be made reusable. Since the OP asked
specifically for a Combobox, I decided to offer it as an alternative
to your good suggestions.

Also, in scripting (as constructed and as opposed to client side web)
the security issues of instantiating ActiveX objects is non-
existent.

Tom Lavedas
***********
My System SpecsSystem Spec
Old 07-08-2009   #6 (permalink)
mr_unreliable


 
 

Re: Combobox in windows script host ?

T Lavedas wrote:
Quote:

> I was worried that that object was a later addition to the OS. I
> suspect it came along with Win 2K or so. You are still using Win 98,
> aren't you? It is part of the Windows Forms collection of objects
> provided by a FM20.dll.
>
Tom, as you probably know, fm20.dll is a licensed control. If you
have any version of office (or ofc2k or later) installed, you will
have fm20.dll installed, because fm20.dll provides the "forms"
capability offered by vba. In addition, ms installs fm20 as part
of a couple of other apps. For example, if you download the ms
"ActiveX Control Pad", you will get fm20.dll:

http://msdn.microsoft.com/en-us/library/ms968493.aspx

fwiw, the presence (or absence) of fm20 is not related to using
or not using win98. I use win98 and have had fm20 available
since 2000.

Most likely in your environment, everybody does have a copy
of ms ofc installed -- and as a result they will have fm20 too.
But some cantankerous people, who think they can get a
satisfactory office suite for free, will probably not have
fm20, regardless of the system they have installed.

That is, it doesn't come with ms windows, it comes with
just a couple of ms apps. So therefore, for general
usage, the select tag may be more universally available.

cheers, jw
My System SpecsSystem Spec
Old 07-08-2009   #7 (permalink)
T Lavedas


 
 

Re: Combobox in windows script host ?

On Jul 8, 1:45*pm, mr_unreliable <kindlyReplyToNewsgr...@xxxxxx>
wrote:
Quote:

> T Lavedas wrote:
Quote:

> > I was worried that that object was a later addition to the OS. *I
> > suspect it came along with Win 2K or so. *You are still using Win 98,
> > aren't you? *It is part of the Windows Forms collection of objects
> > provided by a FM20.dll.
>
> Tom, as you probably know, fm20.dll is a licensed control. If you
> have any version of office (or ofc2k or later) installed, you will
> have fm20.dll installed, because fm20.dll provides the "forms"
> capability offered by vba. *In addition, ms installs fm20 as part
> of a couple of other apps. *For example, if you download the ms
> "ActiveX Control Pad", you will get fm20.dll:
>
> * *http://msdn.microsoft.com/en-us/library/ms968493.aspx
>
> fwiw, the presence (or absence) of fm20 is not related to using
> or not using win98. *I use win98 and have had fm20 available
> since 2000.
>
> Most likely in your environment, everybody does have a copy
> of ms ofc installed -- and as a result they will have fm20 too.
> But some cantankerous people, who think they can get a
> satisfactory office suite for free, will probably not have
> fm20, regardless of the system they have installed.
>
> That is, it doesn't come with ms windows, it comes with
> just a couple of ms apps. *So therefore, for general
> usage, the select tag may be more universally available.
>
> cheers, jw
OK. Thanks for setting that straight. If MS Office is installed, it
works great. Otherwise, ...

Tom Lavedas
***********
My System SpecsSystem Spec
Old 07-08-2009   #8 (permalink)
mayayana


 
 

Re: Combobox in windows script host ?

> But some cantankerous people, who think they can get a
Quote:

> satisfactory office suite for free,
I'm still using Lotus WordPro 96. And I've
got OpenOffice in case someone sends me an
MS Office file. (Though in most cases what I get
is a .doc, and I've got a script on my desktop to
strip the 90% bloat out of that and give me a .txt.
So I don't even need OO very often.)

It amazes me that MS manages to sell so many
copies of Office at such high prices. I read recently
that they made $16B on it last year! Somehow they've
managed to stabilize a vast market of people who
simply never even consider not buying Office, and
who assume that everyone else has it. That's not
so surprising from non-tech people who have to
use Office in their work. Those people often don't even
know that a text file can be saved as anything but
a .docx. What *is* surprising is how many experienced
people assume that everyone uses Office.


My System SpecsSystem Spec
Old 07-08-2009   #9 (permalink)
Todd Vargo


 
 

Re: Combobox in windows script host ?

mayayana wrote:
Quote:
Quote:

> > But some cantankerous people, who think they can get a
> > satisfactory office suite for free,
>
> I'm still using Lotus WordPro 96. And I've
> got OpenOffice in case someone sends me an
> MS Office file. (Though in most cases what I get
> is a .doc, and I've got a script on my desktop to
> strip the 90% bloat out of that and give me a .txt.
> So I don't even need OO very often.)
>
> It amazes me that MS manages to sell so many
> copies of Office at such high prices. I read recently
> that they made $16B on it last year! Somehow they've
> managed to stabilize a vast market of people who
> simply never even consider not buying Office, and
> who assume that everyone else has it. That's not
> so surprising from non-tech people who have to
> use Office in their work. Those people often don't even
> know that a text file can be saved as anything but
> a .docx. What *is* surprising is how many experienced
> people assume that everyone uses Office.
I don't consider those people experienced. They just use what they were
taught to use (or forced to use by the thugs in IT). It drives me nuts when
someone emails a 15MB, single page, PowerPoint to explain something simple
as how to flip a power switch on, when a few lines of text would suffice.

--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)

My System SpecsSystem Spec
Old 07-10-2009   #10 (permalink)
mr_unreliable


 
 

Re: Combobox in windows script host ?



mayayana wrote:
Quote:

> I'm more surprised by the extreme dedication of the
> Office users. Awhile back a friend wanted MS Word and
> we found him a legal version of Word97 online for $35.
> At the other extreme is an architecture firm where I
> was meeting a friend for lunch one day. He said he was
> thinking of updating all of their Office 2000 to the next
> version. (Office XP?) At the time the next version had
> recently come out. I asked why he would spend all of
> that money when Office 2000 was working fine. He
> replied that it looked "unprofessional" to be using an
> older version.
This thread is getting way off-topic, but I couldn't
resist commenting on the above...

One would think that clients of an ARCHITECTURE firm
would be more impressed with the latest TECHNICAL
software (for example, the latest-and-greatest AUTOCAD)
rather than the latest in office/admin apps for text
documents and/or spreadsheets.

cheers, jw
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Problem with host script engine Vista account administration
Windows Script Host has no script engine for ".js" files Vista General
script based host Network & Sharing
Windows Script Host Vista performance & maintenance
Script Host Client launched from Windows Service Vista security


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46