davidm / luacom

Microsoft Component Object Model (COM) binding for Lua
http://lua-users.org/wiki/LuaCom
Other
117 stars 52 forks source link

Ideas how to call CreateStroke of MS Ink APl? #14

Open akavel opened 8 years ago

akavel commented 8 years ago

I'm trying to access the MS Ink API. I'm interested in the following signature now:

https://msdn.microsoft.com/en-us/library/windows/desktop/ms695054%28v=vs.85%29.aspx

HRESULT CreateStroke(
  [in]          VARIANT        PacketData,
  [in]          VARIANT        PacketDescription,
  [out, retval] IInkStrokeDisp **Stroke
);
  • PacketData [in] - Specifies the array of packet data. The data is an array of Int32 values which, taken in order, form the array of points (x0, y0), (x1, y1), which is passed into the method within a Variant.
  • PacketDescription [in] - Is a reserved parameter that is currently not implemented.

Which also has an usage demo in MSDN at:

https://msdn.microsoft.com/en-us/library/windows/desktop/ms704898%28v=vs.85%29.aspx#code-snippet-2

And which I found to be actually a method on an object named "msinkaut.InkObject.1" apparently (to my significant surprise). I managed to verify that a method with such name gets listed in the output of the following snippet:

com = require 'luacom'
ink = assert(com.CreateObject('msinkaut.InkObject.1'))
com.DumpTypeInfo(ink)
--[[
...
027: CreateStroke                       id=0x16 2 param(s)
...
--]]

I've tried then to call it in a few various ways, but none seemed to succeed (note: "Parametr jest niepoprawny" would translate as "The parameter is incorrect", code 0x80070057; I'm using luacom from luarocks, lists as v1.4-1):

> ink.CreateStroke({20,100,30,110}, nil)
COM exception:(.\src\library\tLuaCOM.cpp,398):Parametr jest niepoprawny.
stack traceback:
        [C]: in function 'CreateStroke'
        stdin:1: in main chunk
        [C]: ?
> ink.CreateStroke({Value={20, 100, 30, 110}; Type="array of int4"}, {Type="variant";Value=nil})
COM exception:(.\src\library\tLuaCOM.cpp,398):Parametr jest niepoprawny.
stack traceback:
        [C]: in function 'CreateStroke'
        stdin:1: in main chunk
        [C]: ?
> ink.CreateStroke({Value={20, 100, 30, 110}; Type="array of int4"}, nil)
COM exception:(.\src\library\tLuaCOM.cpp,398):Parametr jest niepoprawny.
stack traceback:
        [C]: in function 'CreateStroke'
        stdin:1: in main chunk
        [C]: ?
> ink.CreateStroke({20, 100, 30, 110; Type="array of int4"}, nil)
COM exception:(.\src\library\tLuaCOM.cpp,398):Parametr jest niepoprawny.
stack traceback:
        [C]: in function 'CreateStroke'
        stdin:1: in main chunk
        [C]: ?

Do you have, by any chance, any idea if/how may it be possible to call this successfully with luacom? I know quite well that all this COM stuff is crazy at low level (safearrays, only one error message ever, etc.), so I don't have my hopes very high here, but I just wanted to ask if you potentially could have any ideas what else I could try.

TIA!

edit: tried with ink: instead of ink. too.

ignacio commented 8 years ago

Have you tried enabling the debug log of LuaCOM (IIRC it is stated in the docs how to do that).

I would have thought that this would work. Seems like the correct incantation to me.

ink.CreateStroke({Value={20, 100, 30, 110}; Type="array of int4"}, {Type="variant";Value=nil})

The only thing that LuaCOM does different than the example you provided is that the lower bound of the array is 1 instead of 0. Besides that... Can you try VBScript and see if you can come up with working code?

akavel commented 8 years ago

I looked in the docs and it seems one has to rebuild the library to enable logging? I use it as a binary LuaRock, recompiling seems more involved.

As to different language, that's what I planned for debugging too, although I used LuaCOM in the first place because I quietly hoped I'll be able to prototype quickly and easily, not that I'll have to dive deep into debugging, eh...

On Fri, Mar 11, 2016 at 5:28 PM, Ignacio Burgueño notifications@github.com wrote:

Have you tried enabling the debug log of LuaCOM (IIRC it is stated in the docs how to do that).

I would have thought that this would work. Seems like the correct incantation to me.

ink.CreateStroke({Value={20, 100, 30, 110}; Type="array of int4"}, {Type="variant";Value=nil})

The only thing that LuaCOM does different than the example you provided is that the lower bound of the array is 1 instead of 0. Besides that... Can you try VBScript and see if you can come up with working code?

— Reply to this email directly or view it on GitHub https://github.com/davidm/luacom/issues/14#issuecomment-195439198.