Running external program without flashing command line

(Simplest solution: avoid to run the plugin on Windows)

There are several criteria that seem to exclude each other when working out a solution for Windows.

  1. You want to run it “quiet” and avoid the black scary command prompt.
  2. You may not want to freeze SketchUp’s single-threaded Ruby process and the whole UI: not completely synchronous.
  3. You may want to know when it is finished: not completely asynchronous.
  4. You may want to have stdout and stderr.

I thought my old TextureResizer code was ugly and I wanted to renovate it. Most of all I wanted get rid of writing output to temporary files. After a long research it turned out the only, commonly used solution was similar to what I already had. Take a look into the latest async_batch.rb in TextureResizer on EWH (my API wraps it into a promise which you maybe do not need).

  1. Running a batch file with call or start always opens a black GUI window. The standard work-around is to invoke it from a visual basic script with wscript.
  2. I dispatch the process asynchronously.
  3. I have to observe when the external process completes. Currently I do this with SketchUp’s asynchronous UI timer.
  4. To get stdout/stderr from an IO object, you would need to run synchronously. But when you use handle = WsShell.Exec you get again a flashing black window. Otherwise, the output is empty and the only workaround is to write&read it from a file.

It is 2018 and this is a sad story.

1 Like