# attachRecording method in WatirMaker script

**URL:** <https://www.ruby-forum.com/t/attachrecording-method-in-watirmaker-script/70251>\
**Category:** Ruby\
**Created:** [September 27, 2006, 7:27pm UTC](https://www.ruby-forum.com/t/attachrecording-method-in-watirmaker-script/70251 "2006-09-27T19:27:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mhinton](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/8edcca/32.png) [@mhinton](https://www.ruby-forum.com/u/mhinton)\
**Post date:** [September 27, 2006, 7:27pm UTC](https://www.ruby-forum.com/t/attachrecording-method-in-watirmaker-script/70251/1 "2006-09-27T19:27:36Z")

</div>

I modified the watirmaker script  
[http://www.hanselman.com/blog/content/binary/WatirMaker.rb.txt](http://www.hanselman.com/blog/content/binary/WatirMaker.rb.txt)  
to contain the following method right under startRecording

def attachRecording

```
# initialize IE
require 'watir'
@watirie = Watir::IE.attach(:title,/#{$windowName}/)
@ie = @watirie.getIE()
@ie.visible = TRUE

browserEvents = WIN32OLE_EVENT.new( @ie, 'DWebBrowserEvents2' )
browserEvents.on_event { |*args| browserEventHandler( *args ) }

# print script header
puts 

```

“##//////////////////////////////////////////////////////////////////////////////////////////////////”  
puts “##”  
puts “## Watir script recorded by WatirMaker.”  
puts “##”  
puts  
“##//////////////////////////////////////////////////////////////////////////////////////////////////”  
puts “”  
puts “#requires”  
puts “require ‘watir’”  
puts “”  
puts “#includes”  
puts “include Watir”  
puts “”  
puts “ie = IE.attach(:title,/#{$windowName}/}”  
# puts “ie.set\_fast\_speed()” this doesn’t seem to work so well  
with multiple frames  
puts “”

```
# capture events
catch( :done ) {
   loop {
      WIN32OLE_EVENT.message_loop
   }
}

# IE takes a moment to close.
# Making it invisible in the interim produces a slightly nicer

```

user experience.  
@ie.visible = FALSE  
end

And at the end of the file I inserted:

wm = WatirMaker.new  
wm.startRecording if !$windowName  
wm.attachRecording if $windowName

I get the following error:

watirmaker.rb:168: [BUG] Segmentation fault  
ruby 1.8.5 (2006-08-25) [i386-mswin32]

This is found in the attachRecording method at the following:

```
      WIN32OLE_EVENT.message_loop

```

I start the command like this:

ruby -s watirmaker.rb -windowName=“MyTitle”

Any thoughts?

Matthew
