Macro Toolworks and Perfect Keyboard Forums • How to pass Java Script variable to MTW native language
Page 1 of 1

How to pass Java Script variable to MTW native language

Posted: Thu Nov 17, 2016 8:26 pm
by Petr
Q: How to pass Java Script variable to MTW native language?

A: It is possible to exchange Java Script variables and the native macro language variables through registry.

This is a macro that contains JavaScript that puts a text to registry:

Code: Select all

<cmds>
<script_js>
var wsh = new ActiveXObject("WScript.Shell");
var key = "HKCU\\Software\\Pitrinec\\jsVariable1";
var jsVariable1="This is Value1";
wsh.RegWrite (key, jsVariable1, "REG_SZ");
</script_js>
And this is the macro text that reads the text from registry to a variable:

Code: Select all

<cmds>
<reg_getvalue>("HKEY_CURRENT_USER\Software\Pitrinec","jsVariable1","vJsv1")
<msg>(-100,-100,"%vJsv1%","",1,0,0,0)