Forum: Ruby Equivalent of "click_no_wait" using win32ole and threads?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Mandeep B. (Guest)
on 2009-02-06 14:57
Hi guys,

I have a watir script to download few files. In the script I am
currently using "click_no_wait" to download which is working fine.
But if I remove the download file from the backend and then run my
script. The script will hang as because "click_no_wait" expects a
download popup to show. I want my script to be full proof.

So I want something equivalent to "click_no_wait". I have tried using
threads and win32ole library to achieve the same. With the code bellow I
have almost succeeded. This code can click and download the file. The
problem with the code bellow is that both the threads "t" and "s" still
runs after its job is done (does not join with the main thread). I am
not able to figure out why?.

  #require <all required>

  #download the file into the given path
  def download_file(filepath)
    ai ="AutoItX3.Control")
    ret = ai.WinWaitActive($wintitle['502'], "", $sleeptime)
    ai.WinWait($wintitle['502'], "", $sleeptime)
    ai.ControlFocus($wintitle['502'], "", "&Save")
    sleep 1
    ai.ControlClick($wintitle['502'], "", "&Save", "left")
    ai.WinWait($wintitle['503'], "", $sleeptime)
    sleep 1
    ai.ControlSend($wintitle['503'], "", "Edit1", filepath)
    sleep 1
    ai.ControlClick($wintitle['503'], "", "&Save", "left")
    sleep 1
    # wait for the window to manually close after download. Time out,
    # as that might be the case when browser download window
    # closes the window with option "Close the dialog box when download
    # or something similar.
    ret = ai.WinWaitActive($wintitle['504'], "Close", $maxsleeptime)
    sleep 1
    if ret == 1
      ai.ControlClick($wintitle['504'], "", "Close")
    sleep 1
  end #end of download_file()

  ie =
  ie.goto "http://myportal/downloads"
  #click on download guide
  t ={, /Download guide/).click
  s ={
    sleep 30

Please suggest, what is that I am doing wrong. Also let me know if there
is other alternatives.

Thanks in Advance,
This topic is locked and can not be replied to.