Edward Middleton wrote:
> Marvin G├╝lker wrote:
>> "One of the parameters was invalid.". I suppose it's the C array I don't 
>> provide, even if it contains only one element.
> 
> Yes thats the problem.  I was forgetting it was an array.  That means
> that the struct can't be flattened, or more specifically the parent
> struct contains a pointer to the child struct[1] rather the then the
> struct itself.  I am not really sure how to get a pointer to the data of
> a string in ruby.  I think there was a DL method to do this though.
> 
> Edward

Why can't it be flattened? The SendInput() function expects an array of 
INPUT structs, the INPUT struct itself doesn't expect an array of 
KEYBDINPUT structs. Maybe I should write a small C extension that just 
puts my Ruby string into a one-element C array. To provide binaries for 
such a small extension should be possible. On the other hand, I'm not 
sure how MinGW will cope with the types used by the Windows API; as far 
as I know, MinGW is using an old C runtime and many things have changed 
in the WinAPI since then.

> I am not really sure how to get a pointer to the data of
> a string in ruby. 

The documentation for Array#pack says this:
> P     |  Pointer to a structure (fixed-length string)
I've used that already for packing the result of the 
GetMessageExtraInfo() call (which returns a LPARAM), but I'm not sure 
about how it works.

Marvin
-- 
Posted via http://www.ruby-forum.com/.