2009-06-05

Calling external programs

Calling external programs is easy:

system('C:\Program Files\Me\live\ClickSomething.exe')

This is a blocking call so it doesn't return control until the enclosed exe file has run.

However if you want this to click on error messages while you are controlling an application then you need it to return immediately and then to kill the process later, you need something like this:

require 'win32/process'

f = IO.popen('C:\Program Files\Me\live\ClickSomething.exe')

#do work which might generate error dialogs
Process.kill(1,f.pid)

I had loaded up popen3 earlier but I was using that to capture text output.

No comments: