Logan Capaldo wrote:
>
> Did you try the Win32API module?
> 
> You code would look something  like this:
> 
> require 'Win32API'
> 
> sendInput = Win32API.new("user32", "SendInput", ['I', 'P', 'I'], 'I')
> 
> # you'll have to pack the INPUT string in the appropiate manner
> input = some_array.pack(some_fmt)
> 
> sendInput.call(num_inputs, input, sizeofINPUT)

I tried this when I saw the original email, but couldn't get it to work. 
Mapping those funky Windows types is tricky. But anyhow, here is the 
(non-working) code:

require 'Win32API'

SendInput = Win32API.new("user32", "SendInput", ['I','P','I'], 'I')
GetLastError = Win32API.new("kernel32", "GetLastError", [], 'L')

INPUT_MOUSE    = 0
INPUT_KEYBOARD = 1
INPUT_HARDWARE = 2

KEYEVENTF_EXTENDEDKEY = 0x0001
KEYEVENTF_KEYUP       = 0x0002
KEYEVENTF_SCANCODE    = 0x0003

# The Left and Right Windows keys
VK_LWIN          = 0x5B
VK_RWIN          = 0x5C

def send_key(key)
   keyboard_input = [INPUT_KEYBOARD, key[0], 0, 0, 0, 0].pack('LCCLLL')
   SendInput.call(1, keyboard_input, keyboard_input.size())
end

res = send_key('R')
puts "Got result: #{res}"
puts "GetLastError: #{GetLastError.call}"
__END__

If anyone gets this working, I'd like to hear about it.

Ryan