From: Edward Middleton Date: 2009-12-29T19:18:32+09:00 Subject: Re: au3 0.1.1 released Marvin G端lker wrote: > ... That isn't as complicated as it sounds, but there are some problems I > cannot get around. First, how to obtain the size of the INPUT structure? > There's no sizeof keyword in Ruby... pack converts and ruby array to a ruby string which in ruby 1.8 is a sequence of bytes. The size of the string will give you the size in bytes of the struct. > Second, how to transform a unicode char (Windows usually uses UTF-16LE I've found out when working on au3) into a WORD? As far as I know, this is an integer value, but a unicode char like 辰 consists of more than one byte? You use MultiByteToWideChar[1] and WideCharToMultiByte[2], the msdn unicode[3] page has more details on this. I think I mostly input everything in UTF-8 then converted to UTF-16LE because there were issues with BOM using UTF-16LE > Third, as said, how to pack a struct into a struct, in this example: How to pack the KEYBDINPUT into the INPUT struct? And last but not least, how to build up a C array in Ruby? > The easiest way is to flatten struct into one. i.e. INPUT { WORD type WORD wVk WORD wScan DWORD dwFlags DWORD Time ULONG_PTR } I don't have a windows machine to test this on but I believe this is mostly correct. Edward 1. http://msdn.microsoft.com/en-us/library/dd319072%28VS.85%29.aspx 2. http://msdn.microsoft.com/en-us/library/dd374130%28VS.85%29.aspx 3. http://msdn.microsoft.com/en-us/library/dd374081%28VS.85%29.aspx