开发者

Current stable xlib wrapper for ruby?

My project has simple requirements:

  1. Grab the contents of an existing xorg app's window

    (do some ocr)

  2. Draw something over the existing app's window (to an overlay)

Requirement 2 isn't so important, I could settle for copying the window to my own.

I spent the morning wasting time with limited and out of date projects:

hornet's eye (couldn't find how to reference an existing window)
matju's RubyX11 (wanted ruby 1.7)
moriq's ruby-xlib (unsigned int for int errors during compile)
xlib-wrap (more type errors)

So apart from using c with xlib or xcb, is there a decent current and stable library or language I can use for fast development? Any language is fine but I w开发者_如何学Goould prefer ruby.


In the end I went with qt4-qtruby:

require 'Qt4'
app = Qt::Application.new(ARGV)
p = Qt::Pixmap.grabWindow(0x182183b) #param is xlib id from xwininfo 

Build script I used:

sudo apt-get install qt-sdk libsmokeqt4-dev
cmake \
-DRUBY_EXECUTABLE=`which ruby` \
-DRUBY_INCLUDE_PATH=$MY_RUBY_HOME \
&& make && make install


I started writing a wrapper around a subset of Xlib. I wrapped quite a bit. You may want to look at the C code and Ruby examples and hack on this to make it do what you want.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜