"Ken" <kpeterk@xxxxxx> wrote
Quote:
> Hello! I'm kind of new at this but I need a little help. I've created
> an HTA application. I'd like to create a text box and then assign
> buttons to run vbscripts against whatever is typed into the box. Is
> this possible?
>
> For instance:
>
> Text box: Enter Computer name
> Button: Get whatever value was typed in the box and run a script to
> find out who is logged into the PC
You have most of it done, the only thing left is to link it all together.
If you include your scripting in the HTA file, you won't need to call out
to other script files. (You still can if you want...)
To link the buttons to their scripts you simply set the 'onClick' value of the
buttons to point to the VBScript Subs you want run. You can get the textbox
contents by naming the textbox in the HTML and using that name in the script.
If you have multiple buttons to run different scripts, put the different scripts in
their own Sub routines and set the button 'onClick' values to point to the
respective Subs for each button.
The example HTA app posted below only has one textbox and one button.
The textbox is named 'user' and the button calls 'RunScript' when clicked.
Note how the 'onClick' value of the button points to RunScript, and
how the contents of the textbox is accessed the the RunScript Sub....
HTH
LFS
------ HTA code from here to end of message ------
<html>
<head>
<title>Link Maker</title>
<SCRIPT Language="VBScript">
' Title: Link Maker
' Author: Larry Serflaten
' Problem: You see a URL in text somewhere and you want to save the target to disk.
' To save it you need it showing as an HTML link so you can right click
' and use the "Save As" context menu item to save the file.
' Usage: Run this HTA, paste the URL into the textbox and press the button.
' The words "The link" are made to point to the entered URL to allow
' saving of the target file.
window.ResizeTo 700, 150
</SCRIPT>
<HTA:APPLICATION
ID="LinkMaker"
APPLICATIONNAME="LinkMaker"
SCROLL="no"
SINGLEINSTANCE="yes"
WINDOWSTATE="Normal">
</head>
<SCRIPT Language="VBScript">
Sub RunScript()
link.href = user.value
where.innerhtml = user.value
End Sub
</SCRIPT>
<body>
<a href="about
:blank" target="blank" name="link">The link</a href> points to:
<span id="where" style="font-weight:800;">about
:blank</span>
</br>
Enter the URL you want linked to, then press the button to change the link:
<input type="text" name="user" size="107">
<input type="button" value="Change Link" onClick="RunScript">
</body>
</html>