Project

win_gui

0.0
No commit activity in last 3 years
No release in over 3 years
Work with Windows GUI in an object-oriented way. Abstractions/wrappers around GUI-related Win32 API functions
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 1.2.9

Runtime

>= 1.0.13
>= 0.3.27
 Project Readme

win_gui¶ ↑

by

Arvicco

url

github.com/arvicco/win_gui

DESCRIPTION:¶ ↑

WinGui is a module that provides higher-level abstractions/wrappers around GUI-related Win32 API functions. It uses Win gem as a basis, which in turn uses FFI. So (in theory) it should work for any Ruby implementation supporting FFI. In practice, it’s only been tested under mingw and cygwin flavors of Ruby 1.9. Porting to JRuby is under way, waiting for its 1.9 compatibility to mature.

SUMMARY:¶ ↑

Win gem provides Rubyesque wrappers around Win32 API functions, but it is not enough to to make Win32 API calls feel like more or less natural extension of Ruby code. The reason for this, straightforward API wrappers are not object-oriented enough.

For example, here is how you deal with typical GUI-related tasks using Win:

require 'win/gui'
include Win::Gui::Window

window_handle = find_window('WinClass', nil)
title = window_text(window_handle )
thread, process = window_thread_process_id(window_handle)
puts window_handle, title, thread, process

enum_child_windows(window_handle, message) do |child_handle, message|
  title = window_text(child_handle )
  thread, process = window_thread_process_id(child_handle)
  puts child_handle, title, thread, process
end
close_window(window_handle)

This works fine, but such functional style just does not feel like object-oriented Ruby. Ideally, there should be a thin wrapper class around window handle, and the code above should be more like this:

require 'win_gui'
include WinGui

window = Window.find(:title => /PartTitle/)
puts window.handle, window.title, window.thread, window.process
window.children.each {|child| puts child.handle, child.title, child.thread, child.process }
window.close

WinGui library strives to provide such wrappers and convenience methods that will make working with Windows GUI-related code much more fun than it is right now.

REQUIREMENTS:¶ ↑

Only works with Ruby 1.9 compatible implementations since Win gem uses some of latest Ruby features.

INSTALL:¶ ↑

$ sudo gem install win_gui

SYNOPSIS:¶ ↑

require 'win_gui'
include WinGui

More examples will follow when the code is closer to production quality…

CREDITS/PRIOR ART:¶ ↑

This library started as an extension of ideas and code described in excellent book “Scripted GUI Testing with Ruby” by Ian Dees.

Win32::GuiTest by MoonWolf is a port of eponimous Perl library to Ruby (raa.ruby-lang.org/project/win32-guitest). I do not like its Perlisms though.

LICENSE:¶ ↑

Copyright © 2010 Arvicco. See LICENSE for details