[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to "verify" your details, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.
[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Lua
. . -> [Subject]  Accessing COM objects from Lua

Accessing COM objects from Lua

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Pages: 1  2  3 

Posted by Nick Gammon   Australia  (23,019 posts)  [Biography] bio   Forum Administrator
Date Reply #30 on Thu 02 Sep 2010 10:25 PM (UTC)

Amended on Fri 03 Sep 2010 01:20 AM (UTC) by Nick Gammon

Message
If you want to find more about the "type library" you can do this:


require "luacom"  -- built into MUSHclient
require "luacom5" -- supplied as luacom5.lua

-- grab raw type library
rawtlb = luacom.LoadTypeLibrary("itunes.Application")

assert (rawtlb, "Type library not found")

-- convert to table
tlb = luacomE.FillTypeLib(rawtlb)  
rawtlb = nil

require "tprint"
tprint (tlb)  --> 17,982 lines ouptput


Example of some of the output:


    71:
      "helpcontext"=0
      "type"="void"
      "description"="True if playback position is remembered."
      "prototype"="void RememberBookmark(VARIANT_BOOL p1)"
      "parameters":
        1:
          "in"=true
          "type"="VARIANT_BOOL"
          "name"="p1"
          "out"=false
          "opt"=false
      "name"="RememberBookmark"
      "num_params"=1
      "dispid"=1610874884
      "rawMethod":
        "helpcontext"=0
        "type"="void"
        "description"="True if playback position is remembered."
        "invkind"="propput"
        "memid"=1610874884
        "name"="RememberBookmark"
        "parameters"=table: 01A75228
        "ParamsOpt"=0
        "helpfile"=""
        "Params"=1
      "typeinv"="propput"



Or you can get a rather nifty HTML document like this:


require "luacom"  -- built into MUSHclient
require "luacom5" -- supplied as luacom5.lua

luacom.DumpTypeLib ("itunes.Application", "c:\\itunes_typelib.html")


(Lengthy file appears in the nominated location). Opening that with your web browser reveals stuff like this:

Quote:


  • Rewind

    void Rewind()

    Skip backwards in a playing track.

    LuaCOM examples:

    com_obj:Rewind()



- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by FenceWalker   USA  (8 posts)  [Biography] bio
Date Reply #31 on Mon 11 Oct 2010 11:00 PM (UTC)

Amended on Mon 11 Oct 2010 11:34 PM (UTC) by FenceWalker

Message
Hello. MC looks to have come along nicely since the last time I used it. I have a question about COM objects in MC and was hoping I might get a little help with a couple of questions.

First I can get info from the program I have the object set up for, like the version of the program, printed to the screen of MC, so that part is ok. Some information that I am trying to view from the object however comes out like this:
table: 05E35C40

Can anyone offer some insight on where I need to go from here to turn that table reference into usable information?

Second I'm a bit confused about what ProgID or ClassID I need to use if I want to set up a COM object for MC to use with another program, if that is possible?

I'm a bit rusty with LUA in general, so try to keep that in mind and maybe dumb responses down a little if anyone has time to reply.
[Go to top] top

Posted by Worstje   Netherlands  (899 posts)  [Biography] bio
Date Reply #32 on Tue 12 Oct 2010 12:47 AM (UTC)

Amended on Tue 12 Oct 2010 12:50 AM (UTC) by Worstje

Message
You'll want to look into Nick's tprint function. Basically, do this:

require "tprint"
tprint(table_of_interest)


Regarding the COM object server functionality.. I am not sure that is possible. I've tried something like that once while trying to abuse the MUSHclient world object, and that basically was a big world of 'let us crash MUSHclient' since MUSHclient is not made to have its own object used outside its own process. (Technically, one probably could consider it a bug, but I think very few people know how to fix it or even need it.)
[Go to top] top

Posted by Nick Gammon   Australia  (23,019 posts)  [Biography] bio   Forum Administrator
Date Reply #33 on Tue 12 Oct 2010 01:48 AM (UTC)
Message
FenceWalker said:

Can anyone offer some insight on where I need to go from here to turn that table reference into usable information?



It might be easier to answer if you gave a specific example. COM can be obscure at the best of times. But if you say something like "I want to play song 3 in my iTunes list", or "I want to get data from Cell A13 in Excel" then that gives us something to get our teeth into.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by FenceWalker   USA  (8 posts)  [Biography] bio
Date Reply #34 on Tue 12 Oct 2010 08:40 AM (UTC)
Message
Yeah I guess I was a bit non descriptive, sorry. Here is the full picture. I am trying to get the values of variables from within CMUD. *gasp* Hehe, specifically I would like to use MC and CMUD together. I have alot of scripts written in in zscript already, but there are plugins for MUSHclient that I would like to use aswell. My idea is if I could get MUSHclient to draw the info from the variables I have populated in CMUD directly I could have the best of both worlds. :)

I am using the folowing:
require("luacom")
require "tprint"
local data = 1

cmud = nil
cmuds = nil
var = nil

if data > 0 then
  cmud = luacom.CreateObject("cMUD.Application")
  cmuds = cmud.CurrentSession
  var = cmuds.getvar(test,"\test")
  data = 0
end

print(var)
tprint(var)


which spits out this:
table: 03E39D88
"_USERDATA_REF_"=userdata: 03E3B330


The variable test actually contains a string of:
This is a test

I would ideally like to have the actual contents of the test variable echoed to MUSHclient be it a string, string list or database variable.
[Go to top] top

Posted by Nick Gammon   Australia  (23,019 posts)  [Biography] bio   Forum Administrator
Date Reply #35 on Wed 13 Oct 2010 08:30 PM (UTC)
Message
Sorry I was a bit slow to respond - got a bit distracted by the mapper.

The easiest thing might be to do what some others have done, and just get at the Access database which I believe Cmud uses. There was someone recently doing that to grab mapper information.

If that doesn't work, you could try looking at the saved data (I think Cmud uses XML?) which you might be able to parse reasonably simply.

Another thing to try would be to follow the example earlier up this page and try to get the HTML type library from the program, like this:


require "luacom"  -- built into MUSHclient
require "luacom5" -- supplied as luacom5.lua

luacom.DumpTypeLib ("cMUD.Application", "c:\\cmud_typelib.html")


I don't have a copy of cMUD so I can't try that, but you might find from that what your next step would be.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by FenceWalker   USA  (8 posts)  [Biography] bio
Date Reply #36 on Fri 15 Oct 2010 03:44 PM (UTC)

Amended on Fri 15 Oct 2010 04:30 PM (UTC) by FenceWalker

Message
Thanks for the help after a couple days of reading and experimentation. I managed to get it working. Adding the line
val = var.value
was needed to actually display what was contained in the variable.


require("luacom")
require("luacom5")

local data = 1

if data == 1 then
  cmud = luacom.CreateObject("cMUD.Application")
  cmuds = cmud.CurrentSession
  var = cmuds.getvar(MSDP,"MSDP")
  val = var.value
  end

print(val)
[Go to top] top

Posted by Nick Gammon   Australia  (23,019 posts)  [Biography] bio   Forum Administrator
Date Reply #37 on Fri 15 Oct 2010 09:24 PM (UTC)
Message
Cool. Now you have a method of getting at all your data.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


128,818 views.

This is page 3, subject is 3 pages long:  [Previous page]  1  2  3 

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]