Page 1 of 1 1
Topic Options
#194658 - 2009-07-10 05:45 PM One way to use the new comable Kixtart.dll
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Was looking for new and novel uses for the new COMable kixtart.dll that comes with the latest version. At least, something that could give an opportunity to play with it a little bit. Wondered how effective it would be as an embedded object in Internet Explorer. Kinda-like being able to script in vbscript and jscript from within HTML ... came up with the following ...

1) Download the lastest build and REGSVR32 KIXTART.DLL

2) Copy the following code to a new file called CONSOLE.HTA

 Code:
<html>
<head>

<hta:application 
 applicationname="KixtartConsole"  
 maximizebutton="no"
 minimizebutton="no"
 singleinstance="yes"
 border="dialog"
 scroll="no">

<title>Kixtart Console</title>

</head>

<style>
BODY
{
   background-color: buttonface;
   font-family: Helvetica;
   font-size: 10pt;
   margin-top: 10px;
   margin-left: 20px;
   margin-right: 20px;
   margin-bottom: 10px;
}

.button
{
   font-family: Helvetica;
   font-size: 8pt;
   width: 92px;

}

textarea
{
   font-family: arial;
   font-size: 10pt;
}

select
{
   font-family: arial;
   font-size: 8pt;
   width: 350px;
   margin-left: 0px;
}

td
{
   font-family: arial;
   font-size: 10pt;
}

</style>

<object classid="clsid:18F66832-6A94-4D70-B7EA-C51ACA6092A4" ID=Kixtart></object>

<body onload="Init()" >

<input type=button value="List Users" onclick="ListUsers();"/>
<input type=button value="List Groups" onclick="ListGroups();"/>
<br>
<textarea name=TextArea1 rows="20" cols="80"></textarea>

</body>

<script language="vbscript">

Function Init()

 Kixtart.SetVar "Document", Document
 Kixtart.SetVar "Window", Window
 Kixtart.SetVar "TextArea1", TextArea1

 Kixtart.RunScript ".\console.kix"

End Function

Function ListUsers()

 Kixtart.SetVar "Function", "ListUsers"
 Kixtart.RunScript ".\console.kix"

End Function

Function ListGroups()

 Kixtart.SetVar "Function", "ListGroups"
 Kixtart.RunScript ".\console.kix"

End Function

</script>    

</html>


3) Copy the following code to a new file (same directory) called CONSOLE.KIX

 Code:
Break On

Select

 Case $Function = "ListUsers"

  $TextArea1.Value = ""

  $WinNT = GetObject("WinNT://@WKSTA")
  $WinNT.Filter = "User",""
  For Each $User In $WinNT
   $TextArea1.Value = $TextArea1.Value + $User.Name + CHR(10)
  Next
  $WinNT = 0

 Case $Function = "ListGroups"

  $TextArea1.Value = ""

  $WinNT = GetObject("WinNT://@WKSTA")
  $WinNT.Filter = "Group",""
  For Each $Group In $WinNT
   $TextArea1.Value = $TextArea1.Value + $Group.Name + CHR(10)
  Next
  $WinNT = 0

 Case 0

EndSelect

Exit 0


4) Run the whole thing with c:\> console.hta

One thing I learned from using the new COMable Kixtart is that when you run a script using RUNSCRIPT(scriptname) method, it runs the script just fine. But you can't run the same script again (well, you can - but anything that can't be multiply defined errors-out, like defining UDF's)

So the script has to be kinda re-entrent (when used in this application).

Anyway, hoping anyone that wants to play and explore can think of even more novel things to do with the KIXTART.DLL

-Shawn

Top
#194664 - 2009-07-10 08:37 PM Re: One way to use the new comable Kixtart.dll [Re: Shawn]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4567
Loc: USA
This looks pretty slick. I'll check it out when I have a few spare moments.
Top
#194672 - 2009-07-11 02:24 AM Re: One way to use the new comable Kixtart.dll [Re: Allen]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11629
Loc: CA
Well if you're wanting to be Admin, you'll have to check it out now


ROFL - Just joking Allen.

Top
#200130 - 2010-10-01 04:29 PM Re: One way to use the new comable Kixtart.dll [Re: Shawn]
semorad2 Offline
Just in Town

Registered: 2010-10-01
Posts: 1
Loc: CZ, Prague
the "serialized" effect of more scripts is SUPER feature. It is much better than vice versa. Thanks for this nice example. It works fine in Windows XP. I have version KiX2010.461 and in VB6/WindowsXP i received following error: "Compile error: Function or interface marked as restricted, or the function uses an Automation type not supported in Visual Basic". In VBNET2008Profi there is following error: System.InvalidCastException was unhandled...(String to UShort)
and folloing does work (but do nothing ;-) ) :
Dim kix As New KiXtart.Application
kix.RunScript(1)
MsgBox("done")
Thus thanks for Your nice workiong example once more!

Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1045 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.052 seconds in which 0.026 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org