Jump to content

ChakraCore UDF - executing JavaScript in AutoIt


scintilla4evr
 Share

Recommended Posts

Is there any way of instantiating the "chakra.dll" in the form of an object?
something similar to as described here (but for C#), where this command 'host = new ChakraHost();" is used to instantiate Chakra as an object, and then the dot notation syntax is used to call the methods 'host.CallFunction("commitFunction");'  ......?

Edited by Chimp

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

3 hours ago, Chimp said:

 

Is there any way of instantiating the "chakra.dll" in the form of an object?

 

I think that would require wrapping the functions in some kind of COM object (AutoItObject for example), since ChakraCore.dll exposes only "flat API", i.e. exported DLL functions. ("Note that JSRT APIs are C++ APIs, this sample assumes a C# wrapper.", as it says on the Embedding ChakraCore page).

Edited by scintilla4evr
Link to comment
Share on other sites

Hi @scintilla4evr, thanks for your answer

I was wondering if what says @guinness  in his topic here, could be used with this chakradll as well..?

anyway, back on your udf, could you show how to use it if, for example, I would like to use the functions from this 'moment' javascript library directly from AutoIt? (library found on this nice site)

any example is welcome

Thank You :)

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

  • 1 month later...
Func _ChakraCore_Startup($sDllFile = "Chakra.dll")

I had to remove the core part from the dll name and then it works. Powefull extension

My output from the examples

  1. JavaScript Output: 5
  2. JavaScript Output: 13
  3. JavaScript Output: llo Wor
  4. JavaScript Output: Lorem ipsum dolor sit amet
  5. a: 320
    b: !dlroW olleH

 

 

 

Link to comment
Share on other sites

  • 1 month later...
On 11/20/2016 at 4:04 PM, PifPaf said:

Help a poor newbie !

Congratulations, but

I can't find out what's wrong with chakracore.au3  when calling a quite basic execution on the example 1 mode :

(function() {
    var h = window.document.location.href ;
    return h ;
})();

Many thanks in advance.

 

test.au3

test.js

Sorry for such a GIGANTIC delay in answering this question.

You can't use window.document.<blah blah insert some object here> in ChakraCore, because the window object is exposed only by web browsers. This UDF only gives access to "raw" JavaScript, so there are no browser-specific objects - no window, navigator, DOM, etc.

Link to comment
Share on other sites

  • 2 years later...
  • 9 months later...

I have a code like this.

(function(helloWorldString1) {
    return helloWorldString1.substr(2, 7);
})();
(function(helloWorldString2) {
    return helloWorldString2.substr(3, 7);
})();
(function(helloWorldString3) {
    return helloWorldString3.substr(4, 7);
})();

How can I get the string result for the last function?

 

Or how can i get multiple result from a js code?

 

Edited by HamidZaeri
Link to comment
Share on other sites

  • 3 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...