The following example integrates autoit to monitor and process the Javascript pop-up window in a separate thread:
Require 'watir'
# Require 'win32ole' # already supported ded if you use 'require watir'
#
# Function to look for popups
Def check_for_popups
Autoit = win32ole. New ('autoitx3. control ')
#
# Do forever-assumes popups cocould occur anywhere/anytime in your application.
Loop do
# Look For window with given title. Give up after 1 second.
Ret = autoit. winwait ('Microsoft Internet Explorer ', '', 1)
#
# If window found, send appropriate keystroke (e.g. {enter}, {y}, {n }).
If (ret = 1) Then autoit. Send ('{enter}') End
#
# Take a rest to avoid chewing up cycles and give another thread a go.
# Then resume the loop.
Sleep (3)
End
End
#
# Main application code
# Setup popup Handler
$ Popup = thread. New {check_for_popups} # Start popup Handler
At_exit {thread. Kill ($ popup)} # Kill thread on exit of Main Application
#
# Main application code follows
Ie = watir: IE. New
Ie. Goto ("http: // localhost: 88/test3.html ")
Ie. Link (: text, "Click here"). Click