|
Description |
OLE Automation object creation |
|
Contents |
In order to automate
Northern Eclipse from another application or script, an OLE automation object
representing Eclipse must be created.
Each supported environment does this differently but the steps are
similar. |
|
|
|
|
Automatic
Code Generation |
Eclipse has a feature
called Autocode that creates working code for you from recorded macros. This generated code will include all
the code necessary to support Eclipse Automation if you select the “Include
Eclipse Initialization Code” option during code generation. |
|
|
|
|
Steps
for manually supporting Eclipse Automation |
1) Create a project or
script file. 2) Include the appropriate
support files if needed. 3) Define an Eclipse
Automation Object. 4) Instantiate the Object. See the appropriate
language example for more details. |
|
|
|
|
Additional
steps (optional) |
1) Verify that the Eclipse
version is correct. The Eclipse.GetVersion command can be used to determine
what the current automation version is.
In addition, you can use the Eclipse.GetReleaseDate and Eclipse.GetReleaseName for additional
information on the currently installed version of Eclipse. 2) Make your application
window “float” on top of Eclipse. This makes your
application stay on top of Eclipse even when the user clicks on Eclipse. Without this command, your
application will be covered up by Eclipse when the user clicks on any Eclipse
Window. This is done with the Eclipse.FloatWindow command. You need to supply a native Windows
Handle to this command. 3) Determine if Eclipse is
already running an automation app. This step MUST be done
before you Instantiate an Automation object or else you will only detect your
own session! Note that if you
use Autocode to generate your code, this code will be created automatically
for you. The registry contains a
flag (of type DWORD) that allows you to determine if an Automation app is
currently running. A non-zero value means that Eclipse is in an Automation
session. Location: “HKEY_CURRENT_USER\Software\Empix
Imaging\Northern Eclipse\5.0\Automation\Active” The registry also contains
a flag (of type Binary, length 1) that allows you to determine if Eclipse is
busy processing (possibly unable to respond to an Automation Request for
connection). A non-zero value of
the first byte means that Eclipse is busy and you should try later to
connect. Location: “HKEY_CURRENT_USER\Software\Empix
Imaging\Northern Eclipse\5.0\General Options\Busy” 4) Shutdown Eclipse at the
end of your application. You can shutdown Eclipse
at the end of your application by using the Eclipse.Shutdown command. |
|
|
|
|
VB Script Example |
VB Scripts can be directly
generated from a recorded macro.
We recommend you use the Autocode feature to generate your VB Scripts. When saving the scripts, make sure
that you use the “.vbs” extension. The following code is automatically
added to the top of all Autocode generated scripts. You can use it as the starting point of your code or never
bother with the coding at all. ‘This section of code
checks to see if a script can connect with Eclipse and fails if it is not
safe to do so. Set WshShell =
WScript.CreateObject("WScript.Shell”) Active=WshShell.RegRead("HKCU\Software\Empix
Imaging\Northern Eclipse\5.0\Automation\Active") Busy=WshShell.RegRead("HKCU\Software\Empix
Imaging\Northern Eclipse\5.0\General Options\Busy") if (
(Busy(0)<>0) OR
(Active<>0) ) then WScript.Echo "Eclipse
is busy! Try again later." : WScript.Quit end if ‘ this section of code
actually connects with Eclipse Dim Eclipse Set Eclipse=CreateObject("Eclipse_Automation") … Add Calls to Eclipse
here |
|
|
|
|
Visual Basic 5/6 Example |
Note: If you want VB.Net
use the dotNET example instead of this one! Create a new (Standard
EXE) Project within Visual Basic.
Add the file “eclipse.bas”
(located in the OLE Sample subdirectory) to the project. This file contains constants that can
be used as arguments for eclipse calls instead of using numeric values. Add the following lines to
the corresponding sections. (General)(Declarations)
section: Dim Eclipse as Object (Form:Load) section: Set Eclipse =
CreateObject("Eclipse_Automation") If Eclipse.GetVersion <
200 Then … insert error message here or call Eclipse.Shutdown() End If (Form:Activate) section: Call
Eclipse.FloatWindow(Form1.hWnd) (your Exit Program Code)
section: Eclipse.Shutdown Set Eclipse=Nothing Testing your
application: 1) Make sure Eclipse is not
currently running (manually or with the method described above) 2) Run your application
from within Visual Basic. 3) Eclipse should load
showing the main splash screen.
If it doesn’t then Eclipse may not have been installed correctly. Also, make sure that Eclipse has been
run at least once in order to make sure that the acquisition driver has been
configured properly. 4) If all goes well, your
form should appear. Clicking on
your Exit button should close your program and unload Eclipse. If your application window disappears
when you click on the Eclipse window then make sure that you entered the
Form:Activate function properly. |
|
|
|
|
Visual C++ 2.0 Example |
Create your project (Windows
EXE) using the MFC AppWizard (make sure that you ask for OLE automation
support, dialog based is also recommended). Add the NEFunctions.cpp
and Invhelp.cpp files to your project.
NEFunctions defines the Eclipse Class that will be used to control
Eclipse. The Invhelp file holds
the ‘automation glue’ code necessary for NEFunctions to work. Don’t forget to also copy the header
files into your project (NEfunctions.h and Invhelp.h). Instantiate an Eclipse
Object by using the following line (either as a class member of your dialog
class or as a global variable) CEclipse Eclipse; Execute the following
lines before making any calls to Eclipse If (Eclipse.GetVersion
< 200) { // insert program shutdown
code here } Eclipse.FloatWindow(CWnd::m_hWnd); Make sure that on
application exit that you call Eclipse.Shutdown Testing your
application: 1) Make sure Eclipse is
not currently running (manually or with the method described above) 2) Compile and run your
application. 3) Eclipse should load
showing the main splash screen.
If it doesn’t then Eclipse may not have been installed correctly. Also, make sure that Eclipse has been
run at least once in order to make sure that the acquisition driver has been
configured properly. 4) If all goes well, your
dialog should appear. Clicking
on your Exit button should close your program. |
|
|
|
|
C# (Microsoft .NET
languages) Example |
All .NET languages
communicate with Eclipse in the same way. The example shown is in C# and uses Windows Forms. Create a new class derived
from System.Windows.Forms.Form. Add the following line to
the top of your class file along with any other using statements that you
need. using Eclipse.Automation; Add a variable to your
class as follows: private COMEclipse Eclipse=new
COMEclipse(true); Add a reference to
Eclipse.Automation.dll Testing your
application: 1) Make sure Eclipse is
not currently running (manually or with the method described above) 2) Compile and run your
application. 3) Eclipse should load
showing the main splash screen.
If it doesn’t then Eclipse may not have been installed correctly. Also, make sure that Eclipse has been
run at least once in order to make sure that the acquisition driver has been
configured properly. 4) If all goes well, your
dialog should appear. Clicking
on your Exit button should close your program. |