64-bit Tablacus Scripting Control

in utopian-io •  7 years ago  (edited)

Tablacus Scripting Control is the 64-bit Alternative of msscript.ocx. Microsoft does not have and will not plan to make a 64-bit Script Control. The Script Control is a very powerful and easy to use tool when you want to do some scripting in your application. This tutorial will guide you with the basis of the 64-bit Tablacus Scripting Control.

Installation & Uninstallation

You can git clone the source code and compile to tsc64.dll using Visual Studio 2015/2017 compiler. Also, you can directly download the pre-compiled binaries.

image.png

The essence of the Tablacus Scripting Control is the tsc64.dll which you need to register as a COM library. You can throw that file into the %WINDIR%\System32 (optional) and run the following command using administrator privileges .

regsvr32 tsc64.dll

On successful registration, it will show the following message indicating tsc64.dll has been installed successfully.

image.png

To remove the script control, you just need to add /u parameter for example:

regsvr32 /u tsc64.dll

How to Use?

For 32-bit Microsoft Script Control, you create a Scripting Object like this:

// JScript
var Obj = new ActiveXObject("MSScriptControl.ScriptControl");
// VBScript
Set Obj = CreateObject("MSScriptControl.ScriptControl")

In 64-bit Tablacus Scripting Control, you need to replace with the following:

// JScript
var Obj = new ActiveXObject("ScriptControl");
// VBScript
Set Obj = CreateObject("ScriptControl")

Setting Language

After creation of the Script Control object, you need to set its language (by default, the Language property is empty), if you don't do this, you probably will run into the following error:

The operation could not be completed because the script engine has not been initialized to a valid language.

You can set to VBScript via sc.Language="VBScript" or sc.Language="VBS" or JScript via sc.Language = 'JScript' or sc.Language = 'Javascript'. JScript is the Microsoft Implementation of Javascript.

AddCode

You then can Add Some code on the fly, for example,

Set Obj = CreateObject("ScriptControl")
Obj.Language = "VBScript"
Obj.AddCode "x = 100"
Obj.AddCode "Msgbox x"

This will print value of variable x which is 100. The AddCode will be executed sequentially. However, the variables defined will be scoped locally so you can't get the variable x via Msgbox x outside, for example.

AddObject

You can pass the object into the script control. This is quite useful as you can pass the UI Object into the script control and the UI can be scripted easily.

Set Obj = CreateObject("ScriptControl")
Obj.Language = "VBScript"
Obj.AddObject "Obj", Obj
Obj.AddCode "Msgbox Obj.Language"

In the above example, the ScriptControl Obj is passed into the script control so you can run code with this object on the fly.

Eval

Eval is to evaluate some expression, for example,

Msgbox Obj.Eval("1+2+3")

will output 6. and the assignment symbol will be treated as comparison instead of 'assignment'. The following output False instead of setting x to 2.

Obj.AddCode("x=1")
MsgBox Obj.Eval("x=2")

ExecuteStatement

Similar to AddCode, ExecuteStatement will be useful to execute a single statement. For example:

Obj.AddObject "Obj", Obj
Obj.ExecuteStatement "Msgbox Obj.Language"

Reset

Reset is useful to clean the Script Control and make a fresh start e.g. clearing the errors and variables. For example:

Obj.AddCode("x=1")
Obj.Reset  ' After Reset, x is deleted.
MsgBox Obj.Eval("x=1")

Conclusion

Scripting Control is fun. Tablacus Scripting Control is 64-bit which allows you to add scripting feature e.g. Macros to your application without re-compiling the application.



Posted on Utopian.io - Rewarding Open Source Contributors

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

大神行长

Thank you for the contribution. It has been approved.

You can contact us on Discord.
[utopian-moderator]

  ·  7 years ago 

Thank you! 谢谢您

  ·  7 years ago 

利害利害!

看不懂,但就是觉得很厉害,那就点个赞😄👍👍

没抢到沙发啊…

厉害厉害!

大神

Hey @justyy I am @utopian-io. I have just upvoted you!

Achievements

  • Seems like you contribute quite often. AMAZING!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x