From: "Marvin Gülker" Date: 2009-11-15T03:43:43+09:00 Subject: Re: How to do a getPixel on Win32 using Ruby? Jian Lin wrote: > Jian Lin wrote: >> Does someone know how to do a getPixel on Win32 using Ruby? (either to >> get a pixel's color value on a window or on the whole screen). thanks. > > ah... and also setPixel() too. Do you want to draw onto the screen? If so, I think you should use a GUI toolkit, create a maximized window, without a title bar and border, and then draw onto it. For example, in wxRuby: ------------------ require "wx" class MyApp < Wx::App include Wx def on_init @mainwindow = Frame.new(nil, -1, "", DEFAULT_POSITION, DEFAULT_SIZE, MAXIMIZE) @mainwindow.background_colour = BLACK Timer.after(3000) do @mainwindow.paint do |dc| dc.pen = WHITE_PEN dc.draw_line(0, 0, 500, 500) end end Timer.after(5000){@mainwindow.close} @mainwindow.show end end x = MyApp.new x.main_loop ------------------- This creates a maximized, black window and after 3 seconds it draws a white line from (0|0) to (500|500). After five seconds (from the beginning) it closes the window. Tested with ruby 1.9.1p243 (2009-07-16 revision 24175) [i386-mingw32] on Windows Vista. Marvin -- Posted via http://www.ruby-forum.com/.