Reputation: 139
Is there anyway I could launch an external program and wait till it opens completely, before opening other files/programs
Example open a powerpoint and after it loads fully then open a word file.
#I have a very specific program at work where I can compare multiple video files on this video player. If the video player is open then via a 'pipe' I could send multiple videos to be opened by the player windowed separately in the same program. The problem is if the video player is closed and if I try to launch multiple videos then they open in multiple instances of the video player and not windowed.
The easier way to replicate this perhaps is say, I would like to open 3 web pages in IE and that all the webpages should be opened in one IE but different tabs and not 3 different IE's. If IE is open in the background then the 3 webpages would probably open in the same instace but different tabs, but if the open command is opening IE then it would launch the 3 webpages in 3 different IE's.
I have tried to open my first file with a 'pipe' and fulevent handler but unfortunately as you have mentioned TCL cannot get any response from external program weather it's done opening fully or not. Without this feedback it makes it tricky to close the pipe and open the next video file. Commands like vwait is another option.. i.e simply wait for the execution on the first command then move ahead to the next.... But that's more like spray and pray, would like something more polished.
Thanks guys for any help
Upvotes: 0
Views: 351
Reputation: 33223
If you use open with a list prefixed with a pipe character then you can launch a subprocess with its standard input and output tied to a Tcl I/O channel. You can then read from that channel and await something that says it is ready if the program supports that (ie a console mode program).
For something like Powerpoint which is a GUI program you can't do this. On Windows, GUI programs do not attach to any standard I/O channels and are launched detached from the parent process. For this you would do better to use COM or OLE Automation using the tcom package.
Presumably you meant to open a powerpoint file using powerpoint as to open a word file one will typically use Word. (tcom::ref createobject Word.Application
for instance).
Upvotes: 2