![]()
|
Launching an application from scriptUsually WITHOBJECT command will launch the server application if it is not running. However it is useful to launch them "manually" sometimes. For example, an application launched by WITHOBJECT is started hidden and doesn't show the normal splash screen, etc. If you need to start CorelDRAW or Corel PHOTO-PAINT in a conventional way, you can use the sample code below. This code uses the automation object name ("CorelPhotoPaint.Automation.9" for example) to determine the path to the executable by looking in the system registry for the application registration information. It uses Windows API function WaitForInputIdle to wait for the application to launch and initialize: DECLARE SUB WaitForInputIdle LIB "user32" \\ (BYVAL ProcID&,BYVAL TimeOut&) ALIAS "WaitForInputIdle" ON ERROR GOTO RegErr CLSID$=REGISTRYQUERY(0,"CorelPhotoPaint.Automation.9\CLSID","") PaintExe$=REGISTRYQUERY(0,"CLSID\"+CLSID+"\LocalServer32","") GOTO Cont RegErr: MESSAGE "Unable to find Photo-Paint 9" STOP Cont: MESSAGE "Path to Photo-Paint is: "+PaintExe+CHR(13)+"Launching..." id&=STARTPROCESS(PaintExe) WaitForInputIdle id, 10000 ' 10 sec timeout MESSAGE "PhotoPaint is launched" END You can use this sample before sending some messages to control the application (for example, see Maximizing Photo-Paint's work area). |
[ CorelSCRIPT Tips&Tricks | Learning CorelSCRIPT | Oberon Home Page ] |
|
Copyright © 2000 by Alex Vakulenko. All rights reserved.
|