topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Thursday March 28, 2024, 12:17 pm
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Any "easy" way to create ActiveX objects (for use with JScript)?  (Read 8081 times)

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,922
    • View Profile
    • Donate to Member
I've been looking for an easy way [1] to create ActiveX objects so that FScript JScript plugins can get access to more functionality.  I haven't found a good way yet, but one thing that looks promising is hinted at in the section titled "Creating a COM component" in the following (plus perhaps using something like py2exe or cx_Freeze):

  http://stormcoders.b...com-with-python.html

I haven't manage to get it working yet (not sure what I'm doing wrong), but I'm wondering if anyone else has tried anything similar or has a better idea.

Any thoughts?


[1] Preferably doable w/ free tools, no nasty license agreements to accept, straight-forward to code, etc.

CWuestefeld

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,009
    • View Profile
    • Donate to Member
Re: Any "easy" way to create ActiveX objects (for use with JScript)?
« Reply #1 on: March 03, 2009, 04:31 PM »
By far the easiest way to code up ActiveX objects is using Visual Basic v6.

It's also possible to create them using VB.Net (or any .Net language) with Interop, and this could be done with the free Express editions I believe, but if you're going to do that, you may as well just use the .Net library.

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,922
    • View Profile
    • Donate to Member
Re: Any "easy" way to create ActiveX objects (for use with JScript)?
« Reply #2 on: March 04, 2009, 12:59 AM »
Thanks for the feedback.

A bit wary w.r.t. .NET regarding deployment among other things -- I don't suppose Mono can be used to achieve similar results (although even if possible, may be this approach would also have similar characteristics -- e.g. size)...not turning up anything yet on this.  Perhaps I will keep looking :)

phitsc

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 1,198
    • View Profile
    • Donate to Member
Re: Any "easy" way to create ActiveX objects (for use with JScript)?
« Reply #3 on: March 04, 2009, 05:04 AM »
Maybe ecaradec could offer a useful selection of WIN32 functions through the IFARR interface. He did do that in the old FScript plugin (exec and getIniValue).

ecaradec

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 410
    • View Profile
    • Blog & Projects
    • Read more about this member.
    • Donate to Member
Re: Any "easy" way to create ActiveX objects (for use with JScript)?
« Reply #4 on: March 04, 2009, 05:38 AM »
Maybe ecaradec could offer a useful selection of WIN32 functions through the IFARR interface. He did do that in the old FScript plugin (exec and getIniValue).

I thought to use the lib_ffi (which is a wrapper that allow script language to call native code ) to allow jscript to call any native functions. However this is a bit laborious to bind with active scripting since nobody seem to have done that before. I'm not sure there is that many functions that would be useful.

You also have the FARR.getObject function available that give you access to the wmi objects. You also have sockets in the recent version. You could implement the functionnalities in a server and communicate via sockets. You could also use another script language that come with libraries that allow many more things than the jscript allow.
Blog & Projects : Blog | Qatapult | SwiffOut | FScript

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,922
    • View Profile
    • Donate to Member
Re: Any "easy" way to create ActiveX objects (for use with JScript)?
« Reply #5 on: March 04, 2009, 06:20 AM »
I thought to use the lib_ffi (which is a wrapper that allow script language to call native code ) to allow jscript to call any native functions. However this is a bit laborious to bind with active scripting since nobody seem to have done that before. I'm not sure there is that many functions that would be useful.

This sounds interesting.  May be I will try to find out more about it.

You also have the FARR.getObject function available that give you access to the wmi objects.

I guess if I understood WMI better I might find this attractive :)  Perhaps it is worth learning more about.

You also have sockets in the recent version. You could implement the functionnalities in a server and communicate via sockets.

Hmm, may be -- I don't suppose you have some sample code? ;)

You could also use another script language that come with libraries that allow many more things than the jscript allow.

This was my original leaning, but the main problem w/ this in my opinion is that the attractive languages to me would be Python, Perl, or Ruby (possibly a few others) -- but none of them ship w/ Windows.  That seems to imply one of:

  • users installing the languages
  • providing plugins that contain code created w/ things like py2exe, perl2exe, rubyscript2exe, and the like

The former I can say from experience working on another FARR-like project that it doesn't tend to work out so well.  The latter I am guessing tends to create rather large plugins (and possibly bloating FARR's runtime footprint?).

I'd be glad to be wrong about using other scripting languages -- may be there is something I'm missing.

ecaradec

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 410
    • View Profile
    • Blog & Projects
    • Read more about this member.
    • Donate to Member
Re: Any "easy" way to create ActiveX objects (for use with JScript)?
« Reply #6 on: March 04, 2009, 09:35 AM »
You can find a socket sample in the fftab plugin. Here is an untested approximative sample :
function write(txt) {
    var sock=FARR.newTCPSocket("localhost",4242);
    sock.write(txt);
    sock.close();
}
function read(txt) {
    var sock=FARR.newTCPSocket("localhost",4242);
    do {
        var fragment=sock.read();
        content+=fragment;
    } while(!content.match(/END_OF_TRANSMISSION$/))
    sock.close();
}

You have to test for something while reading to detect when stopping to read since a read of 0 length can be caused by latency. Note that the loop will use maximum cpu. It would probably better to read asynchronously in a timer.

Blog & Projects : Blog | Qatapult | SwiffOut | FScript