From: Colin Bartlett Date: 2010-04-17T02:06:56+09:00 Subject: Re: How to use AutoIt in Ruby On Fri, Apr 16, 2010 at 5:45 PM, Colin Bartlett wrote: > For example this MsgBox code works in JRuby 1.4 and Ruby 1.8.6 > but (it seems) not in Ruby 1.9.1 (at least not for me!): >  User32_MsgBox = User32[ 'MessageBoxA', 'ILSSI' ] >  result, = User32_MsgBox.call(0, text, title, buttons + icon + modality) > > So if anyone knows how to use "dl" and > Win32API.new( 'user32', 'SendInput', 'IPI', 'I' ) to send keystrokes > (or can pop up a MsgBox in Ruby 1.9.1) > I'd be very interested to see how. Sorry: in case anyone is confused by that User32[...], the "proper" code is: # note that Win32API is deprecated after Ruby 1.9.1 - use dl directly instead require 'dl' User32 = DL.dlopen( 'user32' ) # works in JRuby 1.8 and MRI Ruby 1.8.6, but not in 1.9.1; User32_MsgBox = User32[ 'MessageBoxA', 'ILSSI' ] # User32_MsgBox.call returns an array: # [return_value, [0, text, title, buttons + icon + modality]] # we only want the return value, hence "result, =" result, = User32_MsgBox.call(0, text, title, buttons + icon + modality) puts result But I'd still be interested if anyone can get this to work in Ruby 1.9.1. I get this error message from User32_MsgBox = User32[ 'MessageBoxA', 'ILSSI' ] in '[]': wrong number of arguments(2 for 1) (Argument Error)