iMacros and Java using NetBeans and jawin

Share your tips, tricks and favorite iMacros macros, scripts and applications for web automation in general here.
Forum rules
iMacros EOL - Attention!

The renewal maintenance has officially ended for Progress iMacros effective November 20, 2023 and all versions of iMacros are now considered EOL (End-of-Life). The iMacros products will no longer be supported by Progress (aside from customer license issues), and these forums will also no longer be moderated from the Progress side.

Thank you again for your business and support.

Sincerely,
The Progress Team
Post Reply
Hannes, Tech Support

iMacros and Java using NetBeans and jawin

Post by Hannes, Tech Support » Wed Jun 03, 2009 10:02 am

(Note that we are not affiliated with the NetBean or jawin project. If you use jawin in your project, don't forget to check the jawin license.
And: an Eclipse tutorial can be found here: http://forum.imacros.net/viewtopic.php?t=2703)

1)Download the jawin ZIP from http://sourceforge.net/project/showfile ... e_id=64298, unzip it to some place on your disk

2) Create/Set up NetBeans Java project:

Create new project:
new.project.png
new.project.png (11.05 KiB) Viewed 76851 times
Select Java application:
select.java.application.png
select.java.application.png (33.07 KiB) Viewed 76849 times
Enter project name:
project.name.png
project.name.png (28.89 KiB) Viewed 76855 times
Open dialog to add jawin library:
add.library.png
add.library.png (17.63 KiB) Viewed 76847 times
Select "\lib\jawin.jar" from the unzipped jawin directory:
select.jawin.jar.png
select.jawin.jar.png (29.14 KiB) Viewed 76851 times
Add "\binjawin.dll" from the unzipped jawin directory to the "Windows/system32" folder:
jawin.dll.png
jawin.dll.png (30.31 KiB) Viewed 76843 times
3) Make the "Main.java" look like this:

Code: Select all

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package imacrostest;

//This code makes use of jawin from http://jawinproject.sourceforge.net/
//jawin license: http://jawinproject.sourceforge.net/LICENSE.txt

//two imports from jawin.jar
import org.jawin.DispatchPtr;
import org.jawin.win32.Ole32;

/**
 *
 * @author name
 */
public class Main {

    /**
     * @param args the command line arguments
     */
 public static void main(String[] args) {
      try {
         Ole32.CoInitialize();

         DispatchPtr app = new DispatchPtr("imacros");

         //Calling iMacros methods
         app.invoke("iimInit", null);
         app.invoke("iimPlay", "CODE:URL GOTO=http://www.iopus.com");
         app.invoke("iimPlay", "CODE:TAG POS=1 TYPE=A ATTR=TXT:iMacros EXTRACT=TXT");

         //manually cast return values to correct type
         String iret = app.invoke("iimGetLastExtract").toString();

         app.invoke("iimExit");
                        System.out.println(iret);

         Ole32.CoUninitialize();
      }

      catch (Exception e){
         e.printStackTrace();
      }

   }

}

Done.
Post Reply