I had to do this recently and choose the WinClicker route

basically I have a separate script called by this line just before the
authentication pops up
   
    system("start rubyw.exe window_login.rb #{username} #{password}")

The contents of window_login.rb looks something like this....




class WinClicker
    def getChildHandleAsArray( hWnd )
         handles = Array.new
         
         enum_childWindows = @User32['EnumChildWindows' , 'IIPL' ]
         get_caption_length = @User32['GetWindowTextLengthA' ,'LI' ]  
         get_caption = @User32['GetWindowTextA', 'iLsL' ]
       
         buff = " " * 16
         get_class_name = @User32['GetClassName', 'ILpI']

         bContinueEnum = -1
         enum_childWindows_proc = DL.callback('ILL') {|chwnd,lparam|
              child_handle = chwnd.to_s
              r,rs = get_class_name.call(chwnd, buff, buff.size)
              puts "Found window: " + rs[1].to_s + " Handle: " +
child_handle
             
              handles << child_handle
             
              textLength, a = get_caption_length.call(chwnd)
              captionBuffer = " " * (textLength+1)

              t ,  textCaption  = get_caption.call(chwnd, captionBuffer  ,
textLength+1)   
              puts "Caption =" +  textCaption[1].to_s

              #return chwnd if /#{childCaption}/ =~ textCaption[1].to_s

              bContinueEnum
         }
         r  = enum_childWindows.call(hWnd, enum_childWindows_proc  ,0)
         return handles
    end
end



require 'watir'
include Watir
require 'watir/winClicker'


username = ARGV[0]    
password = ARGV[1]

title = "Enter Network Password"

puts "Waiting for #{title} Window"
sleep 1

w = WinClicker.new

parent_handle = w.getWindowHandle(title)
child_handle = w.getChildHandleAsArray(parent_handle)

w.makeWindowActive(parent_handle)
w.setTextBoxText(child_handle[6].to_i, username) if ARGV[0]  # position
based
w.setTextBoxText(child_handle[8].to_i, password) if ARGV[1]  # position
based
#w.clickWindowsButton_hwnd(parent_handle, "Save this password in your
password list")
w.clickWindowsButton_hwnd(parent_handle, "OK")
_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general

Reply via email to