Giter Club home page Giter Club logo

win_gui's Introduction

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

win_gui's People

Contributors

arvicco avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

win_gui's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.