Integrating With Java

To include SMART Macro Technology into your application, you can use one of the following two approaches. Both of them functionally do the same. But the first approach is significantly quick to develop.

For both the approaches, sample code is provided under the Sample Applications folder.

Default location C:\Program Files\Tethys Macro SDK 2.0\Sample Applications\Java

  1. Use Tethys Macro SDK User Interface (Quick, out of the box solution)
  2. Use Your User Interface (and call Tethys Macro SDK functions)

 

1.  Use Tethys Macro SDK User Interface (Quick, out of the box solution)

Using this solution you can quickly create an application. All you have to do is just call a function ManageMacros and it will show a user interface that lets your users Record, Save, Run macros and manage the properties of each macro. It is that simple.

This solution leverages standard UI components provided by Tethys Macro SDK and saves you the hassle of developing UI or to write code for how to record, run, save and manage macros. This approach let's you gain a competitive edge over others by letting you enter the market first.

Sample Code : The sample code for this solution is provided under \Sample Applications\Java\How To Use SDK UI folder.  The ReadMe.txt file in this folder explains how to work with the sample application. You can also run the sample application to see how it works.

Please follow the steps below & call the following functions in the exact order as specified with mentioned parameters.

Please copy two Tethys Macro SDK files, WKSPSDK.exe and ManageMacros.exe, in the same folder as your application that is going to use them. These files are located in your installation folder. Default C:\Program Files\Tethys Macro SDK 2.0\Lib

  1. To use the SDK the very first function that you need to call in your code is RegisterProduct. If you call any other function without calling this function, it will not behave as expected. If you are using trial version then call SDKObject.RegisterProduct ("TrialUsername", "TrialKey"). If you have purchased the product then pass the username and registration key that you have received upon purchase.

  2. Go to the Lib folder and find the file config.txt.  This is the configuration file that tells the SDK about various properties and their values. Call SetConfigFile function with the path and name of the configuration file. For e.g. SDKObject.SetConfigFile ("C:\Program Files\My Application\Config.txt"). It has a line that reads MacroFolder = C:\MyMacroFolder. This tells the SDK where to store the macros created in your application. Change the property value to point to the appropriate folder in your application.

  3. If you want to record the macros in some other process and not in the same process then you need to call the SDKObject.RegisterApplication function. In this you have to pass the name of the Exe where you want to record. For e.g. if the name of your exe is myExe.exe then the first parameter is "myExe.exe". The second parameter is optional but that is the window title name of your application that you see on the Blue Title bar of the application. We recommend you to pass the exact window title in this function that can help us accurately find the window in which you want to record in case there are multiple instances open of your application.

  4. Call the function SDKObject.ManageMacros without any parameters. This code can be kept in any menu item click event so that when your user clicks on the menu item, it launches our out of the box solution and they can start recording the macros and manage their properties.

           

Your application is ready with the macro technology. Just to summarize the calls to the functions will be in the following order

2.  Use Your User Interface (and call Tethys Macro SDK functions)

Tethys Macro SDK allows you to create your own user interface. Just call the functions like StartRecording, StopRecording, SaveRecording, RunMacro etc. provided by Tethys Macro SDK ActiveX Object.

For e.g. Add the button or menu item to your application to start recording and write the code in your application that calls StartRecording function from WKSPSDK.DLL. 

WKSPSDK.dll is an ActiveX object that provides the set of functions to include SMART Macro Technology from Tethys Solutions, LLC into your products.

This solutions has two sub-types, Approach 1 and Approach 2.

Approach 1: In this approach you can use your User Interface to Record, Stop and Run macro as well as manage macro properties. However you can leverage standard save dialog box, take password from the user, standard dialog box to select the macro to run, validate password etc. This approach will take significantly less time in developing as opposed to Approach 2, which doesn't use any UI component.

Approach 2: In this approach you can use all required functions and develop user interface for every functions you use.

Approach 1:

Please place WKSPSDK.EXE file in the same folder as your application that is going to use them. This file is located in your installation folder. Default C:\Program Files\Tethys Macro SDK 2.0\Lib

Please call the following functions in the exact order as specified below with mentioned parameters.

  1. To use the SDK the very first function that you need to call in your code is RegisterProduct. If you call any other functions without calling this function, they will not behave as expected. If you are using trial version then call SDKObject.RegisterProduct ("TrialUsername", "TrialKey"). If you have purchased the product then pass the username and registration key that you have received upon purchase.

  2. Go to the Lib folder and find the file config.txt.  This is the configuration file that tells the SDK about various properties and their values. Call SetConfigFile function with the path and name of the configuration file. For e.g. SDKObject.SetConfigFile ("C:\Program Files\My Application\Config.txt"). It has a line that reads MacroFolder= C:\MyMacroFolder. This tells the SDK where to store the macros created in your application. Change the property value to point to the appropriate folder in your application. Also set the following parameter-value in the configuration file (Not case sensitive). QuickStart=True. This tells the SDK to use the Save dialog, password validation etc.

  3. If you want to record the macros in some other process and not in the same process then you need to call the SDKObject.RegisterApplication function. In this you have to pass the name of the Exe where you want to record. For e.g. if the name of your exe is myExe.exe then the first parameter is "myExe.exe". The second parameter is optional but that is the window title name of your application that you see on the Blue Title bar of the application. We recommend you to pass the exact window title in this function that can help us accurately find the window in which you want to record in case there are multiple instances open of your application.

  4. To start the recording of the macro, you need to call the function StartRecording.

  5. To stop the recording of the macro you need to call the function StopRecording. Once this function is called, it will bring up a form that asks for a filename to save the macro with and asks if you want to protect the macro with a password or not. All the macros are saved at the location specified by you earlier. The save form will look as shown below

           

  1. To play the recorded macros call the function SDKObject.RunMacro(“quickstart.cfg”).  The parameter value has to be as mentioned i.e. “quickstart.cfg”.  When you call this function, it will bring up a form that shows the list of macros recorded and saved at the location specified in the Config.txt file.  The open form will look as shown below.

           

Just by adding the above code, Tethys Macro SDK will manage for you how to save the macros, handle the case of whether to overwrite the file or not & provide option to password protect the macro while saving. It will also take care of password validation from the user while playing the macro. Please refer to the Sample Application code provided under the Samples folder to get better understanding. It has the exact code as described above.

Just to summarize the calls to the functions will be in the following order.

Approach 2:

Following is the recommended set of directions to get you started with this approach.

  1. Go through the step-by-step instructions provided in ReadMe.txt files in the Sample Application folder. Default location: C:\Program Files\Tethys Macro SDK 2.0\Sample Applications.
  2. Read details about the all the functions provided by the Tethys Macro SDK ActiveX Object.
  3. Read detailed step-by-step instructions for using in Java.

Information about how to use ActiveX Object in Java

Sample code shows how to write code in  Java using JNI to communicate to VC++ dll which in turn calls the Tethys Macro SDK Object functions.

For detailed instructions on how to initialize the object in Java and use it please click the following link

Detailed instructions to use ActiveX Object in Java