however, if I use similar code within the script itself, it doesn’t seem
to execute?
I’m nt quite sure how to proceed with this…
One thing I’ve been wondering is whether I should spawn a new process or
thread in order to deal with this?
I use similar code in some of my scripts:
sleep(1)
if ws.AppActivate(“Security Alert”)
ws.SendKeys “{ENTER}”
sleep(1)
end
It runs within the script’s main thread, following the code that might
trigger the security alert dialog.
Note that WScript.Shell’s AppActivate method returns true if it was able
to activate the window, and false otherwise. You can use this to
determine if the AppActivate method was successful before attempting the
SendKeys method. You may also need to toss in a momentary sleep to allow
the dialog to appear before calling AppActivate.
There may be a more elegant solution (loop with timeout, watir method,
etc.), but this is successful for me.
Hope that helps.
David
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.