[#34033] The rights of ruby-core people and Myth of ruby-dev — "NARUSE, Yui" <naruse@...>

Some of you may don't know your rights.

32 messages 2011/01/03
[#34067] Re: The rights of ruby-core people and Myth of ruby-dev — Aaron Patterson <aaron@...> 2011/01/04

On Tue, Jan 04, 2011 at 06:55:47AM +0900, NARUSE, Yui wrote:

[#34043] proposal: gem_prelude needs to die — Ryan Davis <ryand-ruby@...>

I think it is time for gem_prelude to die.

21 messages 2011/01/04
[#34077] Re: proposal: gem_prelude needs to die — Tanaka Akira <akr@...> 2011/01/05

2011/1/4 Ryan Davis <ryand-ruby@zenspider.com>:

[#34091] Moving to Git? — Lucas Nussbaum <lucas@...>

Hi,

87 messages 2011/01/05
[#34099] Re: Moving to Git? — KOSAKI Motohiro <kosaki.motohiro@...> 2011/01/05

> Hi,

[#34103] Re: Moving to Git? — "U.Nakamura" <usa@...> 2011/01/05

Hello,

[#34105] Re: Moving to Git? — Rodrigo Rosenfeld Rosas <rr.rosas@...> 2011/01/05

Em 05-01-2011 13:15, U.Nakamura escreveu:

[#34106] Re: Moving to Git? — "NARUSE, Yui" <naruse@...> 2011/01/05

(2011/01/06 0:46), Rodrigo Rosenfeld Rosas wrote:

[#34112] Re: Moving to Git? — Jon <jon.forums@...> 2011/01/05

> > Well, I guess I can help listing some advantages. Using git:

[#34118] Re: Moving to Git? — mathew <meta@...> 2011/01/05

On Wed, Jan 5, 2011 at 11:28, Jon <jon.forums@gmail.com> wrote:

[#34121] Re: Moving to Git? — Rodrigo Rosenfeld Rosas <rr.rosas@...> 2011/01/05

Em 05-01-2011 17:16, mathew escreveu:

[#34129] Re: Moving to Git? — mathew <meta@...> 2011/01/05

On Wed, Jan 5, 2011 at 13:23, Rodrigo Rosenfeld Rosas

[#34138] Re: Moving to Git? — Czarek <cezary.baginski@...> 2011/01/05

On Thu, Jan 06, 2011 at 06:50:24AM +0900, mathew wrote:

[#34188] Re: Moving to Git? — mathew <meta@...> 2011/01/06

On Wed, Jan 5, 2011 at 17:02, Czarek <cezary.baginski@gmail.com> wrote:

[#34191] Re: Moving to Git? — Lucas Nussbaum <lucas@...> 2011/01/06

On 07/01/11 at 01:05 +0900, mathew wrote:

[#34201] Re: Moving to Git? — mathew <meta@...> 2011/01/06

On Thu, Jan 6, 2011 at 10:36, Lucas Nussbaum <lucas@lucas-nussbaum.net> wrote:

[#34206] Re: Moving to Git? — Lucas Nussbaum <lucas@...> 2011/01/07

On 07/01/11 at 08:07 +0900, mathew wrote:

[#34227] Re: Moving to Git? — mathew <meta@...> 2011/01/07

On Thu, Jan 6, 2011 at 23:50, Lucas Nussbaum <lucas@lucas-nussbaum.net> wrote:

[#34231] Re: Moving to Git? — Daniel Bovensiepen <bovensiepen@...> 2011/01/07

Dear all,

[#34116] Re: Moving to Git? — Yukihiro Matsumoto <matz@...> 2011/01/05

Hi,

[#34117] Re: Moving to Git? — Rodrigo Rosenfeld Rosas <rr.rosas@...> 2011/01/05

What kind of Redmine integration you are talking about? We use Redmine

[#34120] Re: Moving to Git? — Yukihiro Matsumoto <matz@...> 2011/01/05

Hi,

[#34125] Re: Moving to Git? — Nikolai Weibull <now@...> 2011/01/05

On Wed, Jan 5, 2011 at 19:57, Yukihiro Matsumoto <matz@ruby-lang.org> wrote:

[#34124] [Ruby 1.9-Bug#4235][Open] svn keywords in code prevent correct building of ruby using git mirror — Stephen Bannasch <redmine@...>

Bug #4235: svn keywords in code prevent correct building of ruby using git mirror

12 messages 2011/01/05

[#34171] [Ruby 1.8-Feature#4239][Open] Let's begin a talk for "1.8.8" -- How's needed for surviving 1.8? — Shota Fukumori <redmine@...>

Feature #4239: Let's begin a talk for "1.8.8" -- How's needed for surviving 1.8?

104 messages 2011/01/06
[#34514] [Ruby 1.8-Feature#4239] Let's begin a talk for "1.8.8" -- How's needed for surviving 1.8? — Zeno Davatz <redmine@...> 2011/01/15

Issue #4239 has been updated by Zeno Davatz.

[#34516] Re: [Ruby 1.8-Feature#4239] Let's begin a talk for "1.8.8" -- How's needed for surviving 1.8? — "NARUSE, Yui" <naruse@...> 2011/01/15

(2011/01/16 0:11), Zeno Davatz wrote:

[#34214] [Ruby 1.9-Feature#4247][Open] New features for Array#sample, Array#choice — Yoji Ojima <redmine@...>

Feature #4247: New features for Array#sample, Array#choice

10 messages 2011/01/07

[#34267] [Ruby 1.9-Feature#4254][Open] Allow method transplanting — Jonas Pfenniger <redmine@...>

Feature #4254: Allow method transplanting

23 messages 2011/01/09
[#34280] Re: [Ruby 1.9-Feature#4254][Open] Allow method transplanting — Yukihiro Matsumoto <matz@...> 2011/01/10

Hi,

[#34299] [Ruby 1.9-Bug#4256][Open] [BUG] Segmentation fault ruby 1.9.2p0 (2010-08-18) [i386-mingw32] — Rama Mahendravada <redmine@...>

Bug #4256: [BUG] Segmentation fault ruby 1.9.2p0 (2010-08-18) [i386-mingw32]

9 messages 2011/01/10

[#34318] ext/bigdecimal/lib/bigdecimal/util.rb — Aaron Patterson <aaron@...>

Hi Murata!

14 messages 2011/01/11
[#34321] Re: ext/bigdecimal/lib/bigdecimal/util.rb — Yukihiro Matsumoto <matz@...> 2011/01/11

Hi,

[#34354] [Ruby 1.9-Feature#4264][Open] General type coercion protocol for Ruby — Charles Nutter <redmine@...>

Feature #4264: General type coercion protocol for Ruby

33 messages 2011/01/11
[#34359] Re: [Ruby 1.9-Feature#4264][Open] General type coercion protocol for Ruby — Jim Weirich <jim.weirich@...> 2011/01/11

[#34355] [Ruby 1.9-Feature#4265][Open] Provide a core method Kernel#ruby for invoking a new Ruby instance — Charles Nutter <redmine@...>

Feature #4265: Provide a core method Kernel#ruby for invoking a new Ruby instance

15 messages 2011/01/11

[#34362] [Ruby 1.9-Bug#4266][Open] Timeouts in threads cause "ThreadError: deadlock; recursive locking" — Christopher Bottaro <redmine@...>

Bug #4266: Timeouts in threads cause "ThreadError: deadlock; recursive locking"

12 messages 2011/01/11

[#34399] [Ruby 1.9-Bug#4272][Open] rb_enc_str_new() causes segmentfault when using threads in parallel — Iñaki Baz Castillo <redmine@...>

Bug #4272: rb_enc_str_new() causes segmentfault when using threads in parallel

14 messages 2011/01/12

[#34534] [Ruby 1.9-Bug#4283][Open] Timeout.timeout may cause application exit unintetionally — Motohiro KOSAKI <redmine@...>

Bug #4283: Timeout.timeout may cause application exit unintetionally

11 messages 2011/01/17

[#34537] [Ruby 1.9-Bug#4285][Open] Ruby don't have asynchrounous exception safe syntax and It should have. — Motohiro KOSAKI <redmine@...>

Bug #4285: Ruby don't have asynchrounous exception safe syntax and It should have.

12 messages 2011/01/17

[#34550] [Ruby 1.9-Feature#4288][Open] Allow invoking arbitrary method names with foo."something" syntax — Charles Nutter <redmine@...>

Feature #4288: Allow invoking arbitrary method names with foo."something" syntax

13 messages 2011/01/18
[#34616] Re: [Ruby 1.9-Feature#4288][Open] Allow invoking arbitrary method names with foo."something" syntax — Gary Wright <gwtmp01@...> 2011/01/19

[#34577] Importing rubygems 1.5.0 (release candidate) into trunk. — Ryan Davis <ryand-ruby@...>

I'm going to be committing rubygems 1.5.0 into trunk in a bit.

13 messages 2011/01/18

[#34632] Ruby operator equivalent to Groovy's "?." — Rodrigo Rosenfeld Rosas <rr.rosas@...>

One of the few things I like in Groovy that Ruby doesn't support is

19 messages 2011/01/20

[#34634] Returning from the callee — Rodrigo Rosenfeld Rosas <rr.rosas@...>

Sometimes it is useful to be able to return from the callee method.

15 messages 2011/01/20

[#34648] [Ruby 1.9-Bug#4298][Open] Duration of calling String#[] with the same index is strangely related to string length. — Radosław Bułat <redmine@...>

Bug #4298: Duration of calling String#[] with the same index is strangely related to string length.

13 messages 2011/01/20

[#34861] [Ruby 1.9-Feature#4326][Open] Fiber should respond to call() and [] — Aaron Patterson <redmine@...>

Feature #4326: Fiber should respond to call() and []

21 messages 2011/01/26
[#34943] [Ruby 1.9-Feature#4326] Fiber should respond to call() and [] — Charles Nutter <redmine@...> 2011/01/28

Issue #4326 has been updated by Charles Nutter.

[#34954] Re: [Ruby 1.9-Feature#4326] Fiber should respond to call() and [] — Aaron Patterson <aaron@...> 2011/01/28

On Sat, Jan 29, 2011 at 02:58:46AM +0900, Charles Nutter wrote:

[#34957] Re: [Ruby 1.9-Feature#4326] Fiber should respond to call() and [] — Charles Oliver Nutter <headius@...> 2011/01/29

On Fri, Jan 28, 2011 at 5:29 PM, Aaron Patterson

[#34869] make ruby support line continuations ? — Marc Chantreux <khatar@...>

hello,

22 messages 2011/01/26
[#34878] Re: make ruby support line continuations ? — Jim Freeze <jimfreeze@...> 2011/01/26

> I love it so much i tried it in ruby. trying to rewrite:

[#34887] Re: make ruby support line continuations ? — Marc Chantreux <khatar@...> 2011/01/27

hello,

[#34889] Re: make ruby support line continuations ? — V咜 Ondruch <v.ondruch@...> 2011/01/27

Dne 27.1.2011 7:15, Marc Chantreux napsal(a):

[#34911] The ruby-lang.org downloads page should include RVM for OS X — Andrew Vos <andrew.vos@...>

(I sent this before I subscribed and I'm not sure if it bounced. Sorry if

21 messages 2011/01/27
[#34912] Re: The ruby-lang.org downloads page should include RVM for OS X — "Shota Fukumori (sora_h)" <sorah@...> 2011/01/27

RVM is not official, and makes problem more difficult. (magically

[#34913] Re: The ruby-lang.org downloads page should include RVM for OS X — Andrew Vos <andrew.vos@...> 2011/01/27

What do you mean by "official"? Also, what does it make more difficult? Do

[#34914] Re: The ruby-lang.org downloads page should include RVM for OS X — "Shota Fukumori (sora_h)" <sorah@...> 2011/01/27

return mail is gmail thing. I have same problem.

[#34970] [Ruby 1.9-Bug#4343][Open] Dir.glob does match files without extension — Vit Ondruch <redmine@...>

Bug #4343: Dir.glob does match files without extension

26 messages 2011/01/29
[#34975] [Ruby 1.9-Bug#4343] Dir.glob does match files without extension — Nobuyoshi Nakada <redmine@...> 2011/01/29

Issue #4343 has been updated by Nobuyoshi Nakada.

[#34978] Re: [Ruby 1.9-Bug#4343] Dir.glob does match files without extension — Jeremy Bopp <jeremy@...> 2011/01/29

On 01/29/2011 10:19 AM, Nobuyoshi Nakada wrote:

[#34979] Re: [Ruby 1.9-Bug#4343] Dir.glob does match files without extension — Vít Ondruch <v.ondruch@...> 2011/01/29

Dne 29.1.2011 17:27, Jeremy Bopp napsal(a):

[#34981] Re: [Ruby 1.9-Bug#4343] Dir.glob does match files without extension — Jeremy Bopp <jeremy@...> 2011/01/29

On 01/29/2011 10:33 AM, Vテュt Ondruch wrote:

[#34982] Re: [Ruby 1.9-Bug#4343] Dir.glob does match files without extension — Vít Ondruch <v.ondruch@...> 2011/01/29

Dne 29.1.2011 17:53, Jeremy Bopp napsal(a):

[ruby-core:34349] [Ruby 1.9-Bug#4263][Open] `pack': can't convert Fixnum into String (TypeError)

From: Samuel Treweek <redmine@...>
Date: 2011-01-11 12:44:03 UTC
List: ruby-core #34349
Bug #4263: `pack': can't convert Fixnum into String (TypeError)
http://redmine.ruby-lang.org/issues/show/4263

Author: Samuel Treweek
Status: Open, Priority: Normal
Category: core
ruby -v: ruby 1.9.2p0 (2010-08-18) [i386-mingw32]

I get the following error:
C:/Ruby192/lib/ruby/1.9.1/Win32API.rb:22:in `pack': can't convert Fixnum into String (TypeError)
	from C:/Ruby192/lib/ruby/1.9.1/Win32API.rb:22:in `block in call'
	from C:/Ruby192/lib/ruby/1.9.1/Win32API.rb:21:in `each'
	from C:/Ruby192/lib/ruby/1.9.1/Win32API.rb:21:in `each_with_index'
	from C:/Ruby192/lib/ruby/1.9.1/Win32API.rb:21:in `call'
	from C:/Documents and Settings/samuel.treweeks/Desktop/lib/wintir.rb:73:in `object_exists'
	from C:/Documents and Settings/samuel.treweeks/Desktop/lib/wintir.rb:616:in `initialize'
	from C:/Documents and Settings/samuel.treweeks/Desktop/lib/wintir.rb:147:in `new'
	from C:/Documents and Settings/samuel.treweeks/Desktop/lib/wintir.rb:147:in `button'
	from close_msgbox.rb:6:in `<main>'
0
>Exit code: 1

1. Create folder structure:
main\lib
2. In lib put the attached file 'wintir.rb' file in
3. In Main puts the attached file 'close_msgbox.rb' in
4. Execute close_msgbox.rb
5. Error appears in Win32API

Note: 
This does not occur in Ruby 1.86
The code is trying to close a msgbox opened from a IE


----------------------------------------
http://redmine.ruby-lang.org

Attachments (2)

close_msgbox.rb (337 Bytes, text/x-ruby)
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), 'lib'))
require 'wintir'

com = Wintir::Com.attach(:obj_class => "IEFrame", :name => "VBScript Tutorial - MsgBox - Windows Internet Explorer")
#com.file_menu(:menu_path => "File>Font")
com.dialog(:dialog_name => "VBScript").button(:name => "Button", :caption => "OK").click


wintir.rb (27.3 KB, text/x-ruby)
#Wintir is based on the guitest and watir automation
require "Win32API"
require 'win32ole'
#require "cguitest"


module Wintir
  module GuiTest
    #Find Window
    FindWindow = Win32API.new('user32', 'FindWindow', ["P", "P"], "L")
    #Find sub windows
    FindWindowEx = Win32API.new('user32', 'FindWindowEx', ['P'] * 4, 'L')
    #Get Some Extra Details
    GetClientRect = Win32API.new('user32','GetClientRect','LP','I')
    GetWindowRect = Win32API.new('user32','GetWindowRect','LP','I')
    
    
    class Rect
      # TODO - rather than having Rect know how to unpack the buffer, the caller should
      # do that, and then pass the 4 parameters.  This decouples Rect from knowledge of
      # how the buffer is packed.
      def initialize(buf)
        @left,@top,@right,@bottom = buf.unpack("llll")
        width
        height
        #puts @left,@top,@right,@bottom
      end
      attr_accessor :left, :top, :right, :bottom

      def width
        @width = @right - @left
        #puts @right - @left
      end
      attr_accessor :width

      def height
        @height = @bottom - @top
        #puts @bottom - @top
      end
      attr_accessor :height
    end
    
    def assign_com how, what
      #Find window's handle 
      com = FindWindow.call(how, what)
      query_window com
      
      puts com
      
      return com      
    end
    
    def query_window com
      buf = "\0" * 16
      GetWindowRect.call(com, buf)
      @Rect = Rect.new(buf)
    end
      
  end
end

module Wintir
  class ObjectAssert
    
    SendMessage = Win32API.new("user32", "SendMessage", ['L'] * 4, 'L')
    FindWindowEx = Win32API.new('user32', 'FindWindowEx', ['P'] * 4, 'L')
    
    #Does the object exist
    def object_exists(obj)
     
      #puts obj.com
      
      obj_id = FindWindowEx.call(obj.com,0,obj.name.to_s,obj.caption.to_s) 
      @obj_id = obj_id
  
      return obj_id
 
    end
    attr_accessor :left, :top, :right, :bottom, :obj_id
    #Object Visible/Enabled
    def object_style(obj)
      #puts obj
    end
  end
end


module Wintir
  
  class DialogWindow
 
    FindWindowEx = Win32API.new('user32', 'FindWindowEx', ['P'] * 4, 'L')
    GetWindowTextA = Win32API.new('user32','GetWindowTextA','LPI','I')
    SendMessageA = Win32API.new('user32','SendMessageA','LIIP','I')
    
    def initialize(container, dialog_name)
      #puts container
      @container = container
      get_dialog(dialog_name)
    end
    
    attr_accessor :com
    
    def get_dialog(dialog_name)
      
      #create dialog_title space
      dialog_title = "".center(256)
      
      #32770 is the name for a dialog - brilliant!
      d_hwnd = FindWindowEx.call(0, 0, "#32770", 0)
      
      #Confirm the dialog_name is the one we're after
      GetWindowTextA.call(d_hwnd, dialog_title, 200)
      
      #puts dialog_name
      #puts d_hwnd
      #puts dialog_title.rstrip
      
      
      @com = d_hwnd 
      
    end
    
    def close
       SendMessageA.call(self.com, 16, 0, 0)
    end
      
    def click_button
      #puts "click the button then"
    end

	def static_text
		puts self.com
		t_hwnd = FindWindowEx.call(self.com, 0, 'Static', '')	
		 puts "id #{t_hwnd}"
	end
	

    attr_accessor :name, :attached_text, :zorder, :caption
    
    def button(describe = nil)
      @name=describe[:name]
      @attached_text = describe[:attached_text]
      @zorder = describe[:zorder]
      @caption = describe[:caption]
      
      Button.new(self, describe[:caption], describe[:name], describe[:attached_text], describe[:zorder])
    end
    
    def combo_list(describe = nil)
      @name=describe[:name]
      @attached_text = describe[:attached_text]
      @zorder = describe[:zorder]
      @caption = describe[:caption]
      
      Combo_List.new(self, describe[:caption], describe[:name], describe[:attached_text], describe[:zorder])
     end
    
    def list_box(describe=nil)
      @name=describe[:name]
      @attached_text = describe[:attached_text]
      @zorder = describe[:zorder]
      @caption = describe[:caption]
      
      List_Box.new(self, describe[:caption], describe[:name], describe[:attached_text], describe[:zorder])
    end
    
    def static(describe = nil)
      @static = describe
      @name=describe[:name]
      @attached_text = describe[:attached_text]
      @zorder = describe[:zorder]
      @caption = describe[:caption]
      
      Static_Text.new(self, describe[:caption], describe[:name], describe[:attached_text], describe[:zorder])
    end
    
    def tabs(describe=nil)
      @name=describe[:name]
      @attached_text = describe[:attached_text]
      @zorder = describe[:zorder]
      @caption = describe[:caption]
      
      TabControl.new(self, describe[:caption], describe[:name], describe[:attached_text], describe[:zorder])
    end
    
  end
  
  class Dialog < DialogWindow
    INPUT_TYPES = ["caption", "button", "attached_text", "zorder"]
  end
  
end

#FileMenuInput Class
module Wintir
  class FileMenuInput
    
    FindWindowEx = Win32API.new('user32', 'FindWindowEx', ['P'] * 4, 'L')
    SendMessageAB  = Win32API.new('user32', 'SendMessage', ["L", "L", "P", "P"], "L")
    SendMessageA = Win32API.new('user32','SendMessageA','LIIP','I')
    PostMessageA = Win32API.new('user32','PostMessageA','LIIL','I')
    GetMenu = Win32API.new('user32','GetMenu','L','L')
    GetMenuA = Win32API.new('user32','GetMenu','I', 'I')
    GetMenuItemCount = Win32API.new('user32','GetMenuItemCount','L','I')
    GetMenuStringA = Win32API.new('user32','GetMenuStringA','LIPII','I')
    GetMenuString = Win32API.new('user32','GetMenuString','LIPII','I')
    GetSubMenu = Win32API.new('user32','GetSubMenu','LI','L')
    GetMenuItemID = Win32API.new('user32','GetMenuItemID','LI','I')
   
    
    WM_SETTEXT  = 0x000C
    
    def initialize(container, menu_path)
      
      #puts  container.com
      @container = container
      get_application_menu(menu_path)
           
    end
    
    attr_accessor :container
    
    def click
      #puts "click"
    end

    def get_application_menu(menu_path)
     
      #Delare menu item false
      top_level_menu_item = false
      sub_level_menu_item = false
     
      mi = menu_path.split('>')   
          
      #Get Menu
      h_wnd_menu = GetMenuA.call(container.com)
      #puts h_wnd_menu
     
      menu_count = GetMenuItemCount.call(h_wnd_menu)
      ##puts menu_count
     
      top_menu = "".center(256)
      sub_name = "".center(256)
      sub_l_name = "".center(256)
     
      for i in 0..(menu_count-1) do
       
        GetMenuString.call(h_wnd_menu, i, top_menu, top_menu.length, 1024)
        top_menu_item = top_menu.rstrip
        ##puts top_menu_item.to_s
               
        replace_from = '&'
        replace_to = ''
        top_menu_item = top_menu_item.gsub(/#{replace_from}/, replace_to)
       
        if( /#{mi[0]}/.match(top_menu_item.to_s) )
          #boolean check
          ##puts "Found it #{mi[0]}"
          ##puts top_menu_item
          top_level_menu_item = true
         
        end

        h_view = GetSubMenu.call(h_wnd_menu, i)
        #       #puts h_view
       
        GetMenuString.call(h_view, i, sub_name, sub_name.length, 1024)
        #       #puts sub_name.strip
       
        menu_count1 = GetMenuItemCount.call(h_view)
        for j in 0..(menu_count1-1) do
          GetMenuString.call(h_view, j, sub_l_name, sub_l_name.length, 1024)
       
          sub_menu_item = sub_l_name.rstrip
          ##puts sub_menu_item.to_s
         
          ##puts sub_l_name.strip
          menu_item = GetMenuItemID.call(h_view, j)
          ##puts menu_item
          sub_menu_item = sub_menu_item.gsub(/#{replace_from}/, replace_to)
          ##puts sub_menu_item.to_s
         
          if( /#{mi[1]}/.match(sub_menu_item.to_s) )
            #boolean check
            ##puts sub_menu_item
            ##puts "Found it #{mi[1]}"
            sub_level_menu_item = true
         
          end

          if top_level_menu_item && sub_level_menu_item
            ##puts menu_item
            ##puts h_wnd
            
            #Use PostMessage so as not to wait for confirmation
            PostMessageA.call(@container.com, 273, menu_item, 0) 
            top_level_menu_item = false           
            sub_level_menu_item = false
           
            #puts "Found menu: #{mi[0]} > #{mi[1]}"
          end
         
          #Reset the holding variable to blank
          #open_file(sub_l_name.strip)
          sub_l_name = "".center(256)
        end

        #Reset the holding variable to blank
        sub_name = "".center(256)
        #open_file(sub_l_name.strip)
      end

    end
    
  end
  
  class Filemenu < FileMenuInput
    INPUT_TYPES = ["caption", "name", "attached_text", "zorder"]
  end
end

#Combo Box Class
module Wintir
  class Combolist
    
    FindWindowEx = Win32API.new('user32', 'FindWindowEx', ['P'] * 4, 'L')
    GetComboBoxInfo = Win32API.new('user32','GetComboBoxInfo','LP','L')
    SendMessageA = Win32API.new('user32','SendMessageA','LIIP','I')
    GetClientRect = Win32API.new('user32','GetClientRect','LP','I')    
    GetWindowRect = Win32API.new('user32','GetWindowRect','LP','I')
    
    #Messages
    CB_SELECTSTRING = 333
    CB_GETCOUNT = 326
    CB_GETDROPPEDSTATE = 343
    CB_GETLBTEXT = 328
    CB_GETLBTEXTLEN = 329 
    
    include Wintir::GuiTest    
    
    def initialize(container, caption, name, attached_text, zorder)
      find_combo(container)
      check_attached_text(self.cb_hwnd, attached_text)
      check_attached_text(container.com, attached_text)
           
      #puts caption
    end
  
    def check_attached_text(obj_hwnd, attached_text)
      #puts attached_text
      buf = "\0" * 16
      GetClientRect.call(obj_hwnd, buf)
      @Rect = Rect.new(buf)        
    end
    
    def select_selection(combo_selection)
      
    end
    attr_accessor :name, :attached_text, :zorder, :caption
    
    def find_combo(container)
      
      cb_hwnd = FindWindowEx.call(container.com,0,container.name.to_s,container.caption.to_s)
      @cb_hwnd = cb_hwnd

      #Getting the ComboInfo on hold
      #buf = "\0" * 255
      #GetComboBoxInfo.call(c_hwnd, buf)
      #@combo = ComboInfo.new(buf)
      #puts cb_hwnd
        
    end
    attr_accessor :cb_hwnd
  
    def get_combo_count
      cb_count = SendMessageA.call(self.cb_hwnd, 326, 0, 0)
      return cb_count
    end
    
    def select_string(string)
      #Return Position by integer
      cb_selectstring = SendMessageA.call(self.cb_hwnd, CB_SELECTSTRING, -1, string)
      return cb_selectstring
    end
    
    def get_state
      #Return 1=True
      cb_getdroppedstate = SendMessageA.call(self.cb_hwnd, CB_GETDROPPEDSTATE, 0, 0)
      return cb_getdroppedstate
    end
    
    #ToDO. Failing
    def get_cb_text(position)
      buf = "\0" * 16
      cb_getlbtext = SendMessageA.call(self.cb_hwnd, CB_GETLBTEXT, position, buf)
      a = buf.unpack("l")
      return cb_getlbtext
    end
    
    def get_cb_text_len(position)
      buf = "".center(255)
      cb_getlbtextlen = SendMessageA.call(self.cb_hwnd, CB_GETLBTEXTLEN, position, buf)
      return cb_getlbtextlen
    end
    
  end
  
  class Combo_List < Combolist
    INPUT_TYPES = ["caption", "name", "attached_text", "zorder"]
  end 
  
end

#Static Text Class
module Wintir
  class Static
    
    FindWindowEx = Win32API.new('user32', 'FindWindowEx', ['P'] * 4, 'L')
    GetClientRect = Win32API.new('user32','GetClientRect','LP','I')
    GetWindowRect = Win32API.new('user32','GetWindowRect','LP','I')
    
    include Wintir::GuiTest
    
    def initialize(container, caption, name, attached_text, zorder)
      @com = container.com
      find_static_text(container)
    end
    
    def find_static_text(container)
      st_hwnd = FindWindowEx.call(container.com,0,container.name.to_s,container.caption.to_s)
      get_location_and_size(st_hwnd)
      #puts st_hwnd 
    end
    
    def get_location_and_size(obj_hwnd)
      #GetWindowRect details
      buf = "\0" * 16
      GetWindowRect.call(obj_hwnd, buf)
      @WindowRect = Rect.new(buf)
      
      #GetClientRect details
      buf = "\0" * 16
      GetClientRect.call(obj_hwnd, buf)
      @ClientRect = Rect.new(buf)
    end
    
  end
  
  class Static_Text < Static
    INPUT_TYPES = ["caption", "name", "attached_text", "zorder"]
  end
end

module Wintir
  class TabControl

    SendMessageA = Win32API.new('user32','SendMessageA','LIIP','I')
    FindWindowEx = Win32API.new('user32', 'FindWindowEx', ['P'] * 4, 'L')
    
    TCM_GETITEMCOUNT = 4868
    TCM_GETCURSEL = 4875
    TCM_SETCURSEL = 4876
    
    
    
    def initialize(container, caption, name, attached_text, zorder)
      @com = container.com
      
      find_tab_control(container)
      #get_current_tab(container)
      #puts caption
    end
    
    #find the tab control described
    def find_tab_control(container)
      
      tc_hwnd = FindWindowEx.call(container.com,0,container.name.to_s,container.caption.to_s)
      @tc_hwnd = tc_hwnd
      
    end
    
    attr_accessor :tc_hwnd
    
    def get_current_tab
      cur_tab = SendMessageA.call(self.tc_hwnd, TCM_GETCURSEL, 0, 0)
      #puts cur_tab
      return cur_tab
    end

    def set_tab(index)
      SendMessageA.call(self.tc_hwnd, TCM_SETCURSEL, index, 0)
    end
    
    def get_tab_count
      tb_count = SendMessageA.call(self.tc_hwnd, TCM_GETITEMCOUNT, 0, 0)
      return tb_count
    end
    
    class Tab_Control < TabControl
      INPUT_TYPES = ["caption", "name", "attached_text", "zorder"]
    end
    
  end
end

#List Box Class
module Wintir
  class Listbox
    
    FindWindowEx = Win32API.new('user32', 'FindWindowEx', ['P'] * 4, 'L')
    GetListBoxInfo = Win32API.new('user32','GetListBoxInfo','LP', 'L')
    SendMessageA = Win32API.new('user32','SendMessageA','LIIP','I')
    
    def initialize(container, caption, name, attached_text, zorder)
      @com = container.com
      
      find_list(container)
      #puts caption
    end
  
    def select_selection(combo_selection)
      
    end
    attr_accessor :name, :attached_text, :zorder, :caption
    
    def find_list(container)
      
      lb_hwnd = FindWindowEx.call(container.com,0,container.name.to_s,container.caption.to_s)
      @lb_hwnd = lb_hwnd
      
      no_lb_items = GetListBoxInfo.call(lb_hwnd, container.com)
      @no_lb_items = no_lb_items
      #puts no_lb_items
      
    end
  
    def find_string_item(string)
      lp_Result = SendMessageA.call(self.lb_hwnd, 399, -1, string)
      #puts lp_Result
    end
    
    def select_list_box_value(value)
      SendMessageA.call(self.lb_hwnd, 390, value, 0)
    end
    attr_accessor :lb_hwnd, :no_lb_items
    
  end
  
  class List_Box < Listbox
    INPUT_TYPES = ["caption", "name", "attached_text", "zorder"]
  end 
  
end

#Input Elements
module Wintir
  
  class InputElement  
     
    FindWindowEx = Win32API.new('user32', 'FindWindowEx', ['P'] * 4, 'L')
    SendMessageAB  = Win32API.new('user32', 'SendMessage', ["L", "L", "P", "P"], "L")
    SendMessageA = Win32API.new('user32','SendMessageA','LIIP','I')
    PostMessageA = Win32API.new('user32','PostMessageA','LIIL','I')
    GetWindowRect = Win32API.new('user32','GetWindowRect','LP','I')
    
    WM_SETTEXT  = 0x000C
     
    
    #For setting object color - temp
    #include Wintir::SetObjectColour
    
    
    def intValue  
      @value  
    end  
    def initialize(container, caption, name, attached_text, zorder)
      #set_container container
      
      if is_caption(caption) == true
        #puts "name is good"
      end
       
      if is_name(name) == true
        #puts "name is good"
      end
      
      if is_attached_text(attached_text) == true
        #puts "attached_text is good"
      end
      
      if is_zorder(zorder) == true
        #puts "zorder is good"
      end
     
      #set the value of the text box - Note: Might have to use PostMessage      
      def set(value)
        
        #temp location for setting background object color
        col = Wintir::SetObjectColour.new(self.obj_id)
        col.color_on(self.obj_id)
        
        SendMessageA.call(self.obj_id, WM_SETTEXT, 0, value)
      end
      
      def close
        SendMessageA.call(self.obj_id, 16, 0, 0)
      end
      
      def click
        #puts "click #{@obj_id}"
        PostMessageA.call(@obj_id, 245, 0, 0)
      end
      
      com = ObjectAssert.new
      com.object_exists(container)
      @obj_id =com.obj_id 
  
      #super(nil)
    end
   
    attr_accessor :obj_id
    
    def is_caption(caption)
      if caption != nil and caption != ""
        ##puts "A real name #{name}"
        return true
      end
      
    end
     
    def is_name(name)
      if name != nil and name != ""
        return true
      end
      
    end
    def is_attached_text(attached_text)
      if attached_text != nil and attached_text != "" 
        ##puts "Real text #{attached_text}"
        
        buf = "\0" * 16
        GetWindowRect.call(com, buf)
        @Rect = Rect.new(buf)        
       
        return true
      end
    end
    def is_zorder(zorder)
      if zorder != nil 
        ##puts "Zorder is #{zorder}"
        return true
      end
       
    end
     
  end
  
  class TextField < InputElement
    INPUT_TYPES = ["caption", "name", "attached_text", "zorder"]
  end
  
  class Button < InputElement
    INPUT_TYPES = ["caption", "button", "attached_text", "zorder"]
  end
  
end

#Container Class
module Wintir
  module Container
    
    SendMessageA = Win32API.new('user32','SendMessageA','LIIP','I')    
       
    #text_field (describe) - Describe Edit objects using
    #
    #:name, the real name of the object
    # Usage :name => "txtFirstname"
    # 
    #:attached_text, the text above or to the left of the field
    # Usage :attached_text => "Firstname"
    # 
    #zorder, the position of the edit field on the form, starting from top left -> bottom right
    # Useage :zorder => 0
    def text_field(describe = nil)
      @name = describe[:name]
      @attached_text = describe[:attached_text]
      @zorder = describe[:zorder]
      @caption = describe[:caption]
      
      TextField.new(self, describe[:caption], describe[:name], describe[:attached_text], describe[:zorder] )
    end
    
    attr_accessor :name, :attached_text, :zorder, :caption
    
    def button(describe = nil)
      @name=describe[:name]
      @attached_text = describe[:attached_text]
      @zorder = describe[:zorder]
      @caption = describe[:caption]
      
      Button.new(self, describe[:caption], describe[:name], describe[:attached_text], describe[:zorder])
    end
    
    attr_accessor :menu_path
    
    def close
       SendMessageA.call(self.com, 16, 0, 0)
    end    
    
    def file_menu(describe = nil)
      @menu_path=describe      
      Filemenu.new(self, describe[:menu_path])
    end
    
    attr_accessor :dialog_name
    
    def dialog(describe=nil)
      @dialog_name = describe
      Dialog.new(self, describe[:dialog_name])
    end
    
    def combo_list(describe = nil)
      @combo=describe      
      Combolist.new(self, describe[:combo])
    end
    
    def static(describe = nil)
      @static = describe
      Static_Text.new(self, describe[:caption])
    end
  end  
end

module Wintir

  class Com
      
    CreateProcess = Win32API.new('kernel32','CreateProcess','PPPPILPPPP','I')
    WaitForInputIdle = Win32API.new('user32','WaitForInputIdle','II','I')
    GetDesktopWindow = Win32API.new('user32','GetDesktopWindow','V','L')
    GetWindow = Win32API.new('user32','GetWindow','LI','L')
    GetWindowThreadProcessId = Win32API.new('user32','GetWindowThreadProcessId', 'LP', 'L')
    GetParent = Win32API.new('user32','GetParent','L','L')
    GetForegroundWindow = Win32API.new('user32','GetForegroundWindow', 'V', 'L')
      
    include Wintir::Container
    include Wintir::GuiTest

    def pid
      pid = [0].pack('L')
      hwnd = GetForegroundWindow.call
      GetWindowThreadProcessId.call(hwnd, pid)
      pid = pid.unpack('L')[0]
    end
    

       
    def create_application_window(what)
      create_process(nil, what)
    end
       
    def create_process(lpApplicationName, lpCommandLine, lpCurrentDirectory=nil,
      dwMilliseconds=60000)
      lpStartupInfo = [68].pack("L") + "\0" * 64
      lpProcessInformation  = [0,0,0,0].pack('LLLL')
      CreateProcess.call(lpApplicationName, lpCommandLine, nil, nil, 1, 0, nil,  lpCurrentDirectory, lpStartupInfo, lpProcessInformation)
      hProcess = lpProcessInformation[8,4].unpack('L').first
      
      com = 0
      process_id_count = 0
      #Not a great plan but WaitForInputIdle is failing
      while com == 0 or process_id_count != 10
        com = gethwndfromprocessid(hProcess)
        #counter - so that this isn't endless
        process_id_count = process_id_count + 1
      end
      #puts com
      com = GetForegroundWindow.call
      
      ret = waitForInputIdle(hProcess, dwMilliseconds)
      ##puts ret
      #if dwMilliseconds != 0 and (ret = waitForInputIdle(hProcess, dwMilliseconds)) != 0
      #  raise "createProcess(#{lpCommandLine},#{lpCurrentDirectory},#{dwMilliseconds}):" +
      #    " waitForInputIdle returns #{ret}"
      #end
      @com = com
       
    end
    
    GW_CHILD = 5
    GW_HWNDNEXT = 2
    
    def gethwndfromprocessid(hProcess)
    
      hWnd = GetDesktopWindow.call()
      window_found = false
      
      hWndProcess = [0].pack('L')

      while not window_found and hWnd != 0
        #Get the Child Window
        tmp = hWnd
        hWnd = GetWindow.call(hWnd, GW_CHILD)
        if hWnd != 0 then
          dl = GetWindowThreadProcessId.call(hWnd, hWndProcess)
          hWndProcess = hWndProcess.unpack('L')[0]

          if hWndProcess == hProcess then 
            window_found = true
            #puts "window_found"
          end
          hWndProcess = [0].pack('L')
        else
          hWnd = tmp
          hWnd = GetWindow.call(hWnd, GW_HWNDNEXT)
          if hWnd != 0 then 
            dl = GetWindowThreadProcessId.call(hWnd, hWndProcess)
            hWndProcess = hWndProcess.unpack('L')[0]
            if hWndProcess == hProcess then 
              window_found = true
              #puts "window_found"
            end
            hWndProcess = [0].pack('L')
          else
            hWnd = tmp
            hWnd = GetParent.call(hWnd)
            if hWnd != 0 then 
              branch_found = false
              while not branch_found and not window_found and hWnd != 0
                        
                tmp = hWnd
                hWnd = GetWindow.call(hWnd, GW_HWNDNEXT)
                if hWnd != 0 then 
                  branch_found = true
                  dl = GetWindowThreadProcessId.call(hWnd, hWndProcess)
                  hWndProcess = hWndProcess.unpack('L')[0]
                  if hWndProcess == hProcess then 
                    window_found = true
                    #puts "window_found"
                                
                  end
                  hWndProcess = [0].pack('L')
                else
                  hWnd = tmp
                  hWnd = GetParent.call(hWnd)
                            
                end
              end
            end
          end
        end
      end
      
      @com = hWnd
      return hWnd
      
    end
    
    INFINITE = 0xffffffff   # Infinite timeout
    def waitForInputIdle(hProcess, dwMilliseconds=INFINITE)
      WaitForInputIdle.call(hProcess, dwMilliseconds)
    end
       
    attr_accessor :obj_class, :name, :com

    def initialize_options
      #puts "init opt"
    end

    def _attach_init describe
      @obj_class = describe[:obj_class]
      @name = describe[:name]
     
      attach_com_window @obj_class, @name
      initialize_options
      wait
         
    end

    def self.create describe

      @lpApplicationName = describe[:name]
      @lpCommandLinet = describe[:command_line]

      com = new describe
      com._new_window_init @lpApplicationName
      com
    end

    def self.attach describe
      #Attach the how, what variants
      com = new true
      com._attach_init(describe)
      com
    end

    def initialize describe
      #puts describe
      # _new_window_init describe[:name]
    end

    attr_accessor :name, :command_line

    def _new_window_init what
      create_process(nil, what)
    end

    def self._find(how, what)
      ieTemp = ""
      return ieTemp
    end 

    def wait(no_sleep=false)
      #puts "wait"
    end

    def log(what)
      #puts "log"
      @logger.debug(what) if @logger
    end 

    def attach_com_window how, what 
      log "Seeking Window with #{how}: #{what}"
      #puts "attach com window"
      comTemp = nil
      #begin
      #  Wintir::until_with_timeout do
            
      comTemp = assign_com(how, what)
      #  end
      #rescue TimeOutException
      #  raise NoMatchingWindowFoundException,
      #           "Unable to locate a window with #{how} of #{what}"
      #end
      @com = comTemp
      #return @com
    end
    private :attach_com_window 

  end
   
end


#ComboInfo Class - Needs further investigation
module Wintir
  
  class ComboInfo
  
      def initialize(buf)
        @cbSize,@rcItem,@stateButton,@hwndCombo,@hwndItem,@hwndList = buf.unpack("IPPIII")
        #puts @cbSize
      end
      attr_accessor :cbSize,:rcItem,:rcItem,:stateButton,:hwndCombo,:hwndItem,:hwndList

  end
  
end

module Wintir
  class SetObjectColour
    
    SendMessageA = Win32API.new('user32','SendMessageA','LIIP','I')
#   SetBkColor = Win32API.new('user32', 'SetBkColor', 'LI','L')
    GetWindowDC = Win32API.new('user32','GetWindowDC','L','L')
    SetForegroundWindow = Win32API.new('user32','SetForegroundWindow','L','I')
    GetDC = Win32API.new('user32','GetDC','L','L')
    
    
    EM_SETBKGNDCOLOR = 0x0443
    SET_COLOR_YELLOW = 0xDFFFA5
    
    def initialize(com)
      #ToDo check the object type for correct color change
      
      #puts com
    end
  
    #Turn the background of the object color on
    def color_on(com)
      #yellow
      
      color_on = true
      color_on = SendMessageA.call(com, EM_SETBKGNDCOLOR, 0, SET_COLOR_YELLOW)
      return color_on     
    end
  
    #Protect from user setting background objects color status
    #private :color_on
    
    #Turn the background of the color off
    def color_off
    end
    
    #Get the current color of the objects background
    def get_object_bk_color(com)
      
      #Setting the window to focus call to pixel/color
      SetForegroundWindow.call(com)
      
      #Get the DC
      hdc_source = GetDC.call(com)
      #puts hdc_source
    
    end
    
    #Protect from user setting background objects color status
    #private :color_off
    
  end
end

In This Thread

Prev Next