0.0
No commit activity in last 3 years
No release in over 3 years
There's a lot of open issues
A Ruby library to work with Microsoft Windows' Win32 window management APIs, including search, enumeration, and window manipulation.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

>= 1.4.8
 Project Readme

Win32::Window

Ruby interface to the Win32 window management APIs.

Getting Started

gem install win32-window --pre
require 'win32/window'
include Win32 (optional)

API

Finding a window

By handle. If the handle does not refer to a window, nil is returned.

w = Window.from_handle(h)

By screen coordinates. Returns the top-level window covering the specified coordinates.

w = Window.from_point(x, y)

# Alternatively:
p = Point.new(x, y)
w = Window.from_point(p)

By window title. Returns all top-level windows whose title matches the specified regex. This can return multiple windows.

w = Window.find(:title => /calculator/i)

# Get just the first result.
w = Window.find(:title => /Google Chrome$/).first

By process ID. Returns all top-level windows owned by the specified process ID. This can return multiple windows.

w = Window.find(:pid => 4242)

By custom filter. Returns all top-level windows for which the block holds true. This can return multiple windows.

w = Window.find { |pid, title|
  (pid > 1000) && (title.end_with? 'Notepad')
}

The desktop window. Note that the geometry of this window corresponds to the primary monitor only.

w = Window.desktop

The foreground window. This is the window with which the user is currently working.

w = Window.foreground

Navigating the window hierarchy

w.parent

w.child_of?

Basic properties

w.handle

w.title

w.pid

Geometry

w.size ...

w.client.size ...

w.resize(...)

w.move(...)

Display

w.minimized?, w.minimize

w.maximized?, w.maximize

w.foreground?, w.foregroundize

w.restore

w.visible?, w.hide, w.show

w.topmost?, w.topmost=

License

Copyright © 2013 Chris Schmich
MIT License. See LICENSE for details.