1. Technology
Send to a Friend via Email

Automation of Windows using FFI

Ruby is not real at home on Windows, however JRuby has a great FFI system that can be used to easily (after a fashion) control and automate Windows applications.

Simulating Keystrokes with JRuby
While Ruby and Windows don't always mix that well, we're going to apply just a bit of force and get them to mix. In this series of articles we'll look at automating Windows applications from JRuby.

Automating with Robot
While JRuby can use the FFI (Foreign Function Interface) to get at the Win32 API, there is an easier (if not vastly less powerful) way to do a few things: the Robot class, part of the default Java environment.

Using FFI to Access Win32
Though there are other ways to access the Win32 API, a relatively easy way is to use the FFI (Foreign Function Interface).

Sending Win32 Keyboard Messages with via FFI
Now that we have a cursory understanding of FFI, let's use it to find a specific window and send some keyboard events to it.

Sinatra Web Applications in JRuby
Now that we have the foundation in place, time to build a bit of structure. In this article we'll look at building a frontend using Sinatra.

AJAX With Sinatra
In this article we take a look at how to use jQuery and Sinatra to implement an AJAX interface.

Finishing the Project
This last article just staples the previous articles together. Once you know how to do Win32 API calls and AJAX-powered web applications in Sinatra, it all just falls into place.

You can opt-out at any time. Please refer to our privacy policy for contact information.

©2014 About.com. All rights reserved.