Page 2 of 4
Posted: Sun May 30, 2004 11:17 pm
by techjunkie
[quote="Num3"]I've been messing with VB ActiveX controls and they work just fine

[quote]
Same goes for me... Beautiful work!! Now we are talking...
Thank you! Great stuff!!!!!
Posted: Mon May 31, 2004 8:36 am
by Edwin Knoppert
Do you mean controls?
Do you have a simple example?
Thanks,
Posted: Mon May 31, 2004 7:27 pm
by ricardo
aXend wrote:@Num3 Thanks.
The file requester should keep the last directory you went to...
You are right.

I'm aware that I could do something more on the GUI side of the Interface Generator. Use a Menu and/or Toolbar... I thought it would be useful to publish the tool now, so it can be used. I'll work on improvement from now. Any other suggestions?
I was way from the forums sometime, sorry if i make a stupid question
I make the interface for the MSscript.ocx
Code: Select all
; Interface generated by Interface Generator 1.0, Date 05/31/2004
; MSScriptControl, Microsoft Script Control 1.0
; Enumerations
Enumeration ; ScriptControlStates
#Initialized = 0
#Connected = 1
EndEnumeration
; DispInterfaces
Interface IScriptProcedure Extends IDispatch
get_Name(a)
get_NumArgs(a)
get_HasReturnValue(a)
EndInterface
Interface IScriptProcedureCollection Extends IDispatch
get__NewEnum(a)
get_Item(a,b,c,d,e)
get_Count(a)
EndInterface
Interface IScriptModule Extends IDispatch
get_Name(a)
get_CodeObject(a)
get_Procedures(a)
AddCode(a)
Eval(a,b)
ExecuteStatement(a)
Run(a,b,c)
EndInterface
Interface IScriptModuleCollection Extends IDispatch
get__NewEnum(a)
get_Item(a,b,c,d,e)
get_Count(a)
Add(a,b,c)
EndInterface
Interface IScriptError Extends IDispatch
get_Number(a)
get_Source(a)
get_Description(a)
get_HelpFile(a)
get_HelpContext(a)
get_Text(a)
get_Line(a)
get_Column(a)
Clear()
EndInterface
Interface IScriptControl Extends IDispatch
get_Language(a)
put_Language(a)
get_State(a)
put_State(a)
put_SitehWnd(a)
get_SitehWnd(a)
get_Timeout(a)
put_Timeout(a)
get_AllowUI(a)
put_AllowUI(a)
get_UseSafeSubset(a)
put_UseSafeSubset(a)
get_Modules(a)
get_Error(a)
get_CodeObject(a)
get_Procedures(a)
_AboutBox()
AddObject(a,b,c)
Reset()
AddCode(a)
Eval(a,b)
ExecuteStatement(a)
Run(a,b,c)
EndInterface
Which is the next step to be able to use it in PB?
Posted: Mon May 31, 2004 8:00 pm
by aXend
As described in the documentation you can download COMLIB from
http://home.planet.nl/~aXend/purebasic/COMLIB_demo.zip. This LIB contains the function
After that you can do
as found in the Interface.
You have to find the meaning of the methods and properties in the manuals of MSScript. I can't help you with that.
Posted: Mon May 31, 2004 9:25 pm
by Edwin Knoppert
Is it possible to have visible controls?
Posted: Mon May 31, 2004 10:40 pm
by ricardo
aXend wrote:As described in the documentation you can download COMLIB from
http://home.planet.nl/~aXend/purebasic/COMLIB_demo.zip. This LIB contains the function
After that you can do
as found in the Interface.
You have to find the meaning of the methods and properties in the manuals of MSScript. I can't help you with that.
Thanks for your answers!
One more question: where did i get the ProgID?
---
In this case the object\function() could be, per example, object\AddCode()?
---
Your application and your library seams very good!!
Thanks in advance for your help

Posted: Mon May 31, 2004 11:02 pm
by ricardo
Doing this don't work, what im doing wrong?
Code: Select all
IncludeFile "msscript interface.pb" ;the interface i show in other post here
Debug object.IScriptControl = CreateObject("MSScriptControl.ScriptControl.1")
Debug object\_AboutBox()
Thanks in advance
Posted: Mon May 31, 2004 11:43 pm
by aXend
I've been playing with ScriptControl. What you did is correct, except for the "Debug object\_AboutBox()". You should leave the Debug and code object\_AboutBox(). This works!
See my test code.
Code: Select all
IncludeFile "MSScriptControl.pb" ; the Interface file
Structure SAFEARRAYBOUND
cElements.l; // The number of elements in the dimension
lLbound.l; // Lowerbound of the dimension
EndStructure
Structure SAFEARRAY
cDims.w; // Count of dimensions in this array.
fFeatures.w; // Flags used by the SafeArray routines documented below.
cbElements.l; // Size of an element of the array. Does not include size of pointed-To Data.
cLocks.l; // Number of times the array has been locked without corresponding unlock.
pvData.l; // Pointer to the data.
rgsabound.SAFEARRAYBOUND[1] ; // One bound for each dimension.
EndStructure
Global None.VARIANT
None\vt = #VT_ERROR
None\scode = #DISP_E_PARAMNOTFOUND
oScript.IScriptControl = CreateObject("MSScriptControl.ScriptControl")
Debug oScript
oScript\_AboutBox()
oScript\put_Language(Ansi2Uni("JScript"))
oScript\get_Language(@language.l)
Debug Uni2Ansi(language)
oScript\get_Timeout(@timeout.l)
Debug timeout
oScript\get_Modules(@oModules.IScriptModuleCollection)
Debug oModules
oModules\Add(Ansi2Uni("TestModule"),None,@oModule.IScriptModule)
Debug oModule
oModule\get_Name(@name.l)
Debug Uni2Ansi(name)
err.l = oModule\AddCode(Ansi2Uni("function Calc() {var x=4*4; return x;}"))
If err = #S_OK
numargs.l = 0
rgsabound.SAFEARRAYBOUND
rgsabound\cElements = numargs
rgsabound\lLbound = 0
*psa.SAFEARRAY = SafeArrayCreate_(#VT_VARIANT,1,rgsabound)
If oModule\Run(Ansi2Uni("Calc"),@*psa,@result.VARIANT) = #S_OK
Debug result\vt
Debug result\value
Else
Debug Hex(err)
EndIf
Else
Debug Hex(err)
EndIf
SafeArrayDestroy_(psa)
err.l = oModule\AddCode(Ansi2Uni("function MyStringFunction(Argu1,Argu2,Argu3) {return Argu1+', '+Argu2+' and '+Argu3;}"))
If err = #S_OK
numargs.l = 3
Dim vArgs.VARIANT(numargs-1)
vArgs(0)\vt = #VT_BSTR
vArgs(0)\bstrVal = Ansi2Uni("Vanilla")
vArgs(1)\vt = #VT_INT
vArgs(1)\lVal = 9999
vArgs(2)\vt = #VT_BSTR
vArgs(2)\bstrVal = Ansi2Uni("Espresso Chip")
rgsabound.SAFEARRAYBOUND
rgsabound\cElements = numargs
rgsabound\lLbound = 0
*psa.SAFEARRAY = SafeArrayCreate_(#VT_VARIANT,1,rgsabound)
For i = 0 To numargs-1
SafeArrayPutElement_(*psa,@i,@vArgs(i)) ; add arguments to SafeArray
Next
If oModule\Run(Ansi2Uni("MyStringFunction"),@*psa,@result.VARIANT) = #S_OK
Debug result\vt
Debug Uni2Ansi(result\value)
Else
Debug Hex(GetLastError_())
EndIf
Else
Debug Hex(err)
EndIf
SafeArrayDestroy_(psa)
oModule\get_Procedures(@oProcedures.IScriptProcedureCollection)
Debug oProcedures
oProcedures\get_Count(@count.l)
Debug count ; should be 2 because 2 procedures were added
For i = 1 To count ; !!! ATTENTION !!!: the counter starts at 1
item.VARIANT\vt = #VT_I4 ; this is the VARIANT type for the index
item\value = i ; this is the index
*item.pToVariant = item ; this cuts the VARIANT in 4 LONG values
; Get a Procedure object by passing the 4 LONG values
If oProcedures\get_Item(*item\a,*item\b,*item\c,*item\d,@oProcedure.IScriptProcedure) = #S_OK
oProcedure\get_Name(@name.l)
oProcedure\get_NumArgs(@args.l)
oProcedure\get_HasReturnValue(@retVal.l)
If retVal = #VARIANT_TRUE
retVal$ = "does"
Else
retVal$ = "doesn't"
EndIf
Debug "Procedure "+Uni2Ansi(name)+" takes "+Str(args)+" arguments "+" and "+retVal$+" return a value"
ReleaseObject(oProcedure)
Else
Debug Hex(GetLastError_())
EndIf
Next
ReleaseObject(oProcedures)
ReleaseObject(oModule)
ReleaseObject(oModules)
ReleaseObject(oScript)
Posted: Tue Jun 01, 2004 12:52 am
by ricardo
Very nice example!!
I understand most of it at first time, the rest will study it with care.
Thanks a lot for the example and for your hard work to bring this powerfull option to PB!
Posted: Tue Jun 01, 2004 1:15 am
by ricardo
A very fast and direct example:
Code: Select all
IncludeFile "msscript interface.pb" ;the one showed here before
object.IScriptControl = CreateObject("MSScriptControl.ScriptControl.1")
object\_AboutBox()
object\put_Language(Ansi2Uni("vbscript"))
object\ExecuteStatement(Ansi2Uni("msgbox " + Chr(34) + "hello msscript from PB" + Chr(34)))
object\ExecuteStatement(Ansi2Uni("Value = (3*3)+100:MsgBox Value"))
ReleaseObject(object)
Have fun!
Posted: Tue Jun 01, 2004 1:52 am
by ricardo
One more question.
What to do when i know there are some 'elements' that are not showed in the interface?
I found this same problem in VB, but there no matter if the elements are not listed, they work.
One example:
If i create the interface for "Shell.Application" i know i can work with all this
Code: Select all
Set oWeb = CreateObject("Shell.Application")
Set Web = Web.Windows
Web.count
Web.Item(i).Document
But in the interface i cant see, per example, item().document
As i said before, this same thing happends when using VB, the intelisense of VB or the object examination DONT show document and many others, but they work if i put it there... in PB what can i done?
In this case:
1.- How can i do this:
Set oWeb = CreateObject("Shell.Application")
Set Web = Web.Windows
2.- Then how can access to
Web. count
Web, Item(i).Document... etc
Because many Activex dont display for some reason all they properties, methods, etc. with the interface but they are there and could be used.
Thanks in advance
Posted: Tue Jun 01, 2004 8:03 am
by aXend
You said this worked with VB, but I tested it and it didn't.
Set oWeb = CreateObject("Shell.Application")
Set Web = Web.Windows
Web.count
Web.Item(i).Document
First I had to change "Set Web = Web.Windows" to "Set Web =
oWeb.Windows".
After that I got the message that "Document" was not a supported method or property with "Web.Item(i)...".
You can do the first three statements with the Interfaces. It would be something like this:
Code: Select all
oWeb.IShellDispatch = CreateObject("Shell.Application")
oWeb\Windows(@Web.Folder3)
Web\Items(@WebItems.FolderItems3)
WebItems\get_Count(@count.l)
I didn't test this yet. I guess you'll have to rearrange the Interface file, because some interfaces refer to others and they're not in the order that PB wants to.
[EDIT] I found that some of the interfaces already exist in PB. I think we have to blame Fred for that...

Posted: Tue Jun 01, 2004 10:25 am
by Fred
Very handy tool, good work aXend !

Posted: Tue Jun 01, 2004 3:53 pm
by ricardo
@aXend
I will try out tonight because want to find a way to go to deeper usages on this, is very interesant!
The Web.Item(i) not only have Document, but many others, in fact has more deeper 'levels': Web.Item(i).Document .All.Tags etc, etc.
That same thing i found in many Activex, that has much more than is listed on the interface. Need to find a way to use it in PB.
Thanks
Posted: Tue Jun 01, 2004 4:03 pm
by Edwin Knoppert
I think you'll need to query using the IID for these interfaces.
I don't think it's useful though.