Using iMacros with JAVA (via the Jawin package) in Eclipse

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

Using iMacros with JAVA (via the Jawin package) in Eclipse

Post by Hannes, Tech Support » Tue Feb 13, 2007 1:46 pm

[Update 2010-08-23]
The Jawin library does not support 64bit. However, there's a replacement called JACOB (http://sourceforge.net/projects/jacob-project/). It's pretty easy to use and the main steps given below still hold. Just replace any reference to jawin with the appropriate JACOB one. Additionally, I have posted a small HowTo here.
[End of update]

[Update]
When running iMacros from Java, you may also be interested in using the iMacros Java wrapper class: http://forum.imacros.net/viewtopic.php?f=14&t=1147
[End of update]

[update]
A tutorial for using NetBeans instead of Eclipse can be found here: http://forum.imacros.net/viewtopic.php?f=6&t=7183
[End of update]



Preliminaries:

1) Download Jawin (http://jawinproject.sourceforge.net/, version 1.0.19, released under this license: http://jawinproject.sourceforge.net/LICENSE.txt), extract to local folder
[Update] Version 2.0-alpha1 also works fine.[End of update]

2) Start Eclipse

Start new project (usign jawin) in Eclipse:

1) File --> New --> Project

Image

2) Java --> Java Project --> Next

Image

3) Enter name: "iMacrosScriptingInterface" --> Next

4) Libraries --> Add External Jars" --> select jawin.jar from the Jawin\lib directory --> Finish

Image

5) Right-click iMacrosScriptingInterface in Package Explorer tab

Image

6) Import --> General --> File System --> Next

Image

7) Browse --> jawin-dir\bin\jawin.dll --> Finish

New Class in project

1) Select iMacrosScriptingInterface in the Package Explorer tab

2) File --> New --> Class

Image

3) Name: iMacrosTest --> Finish

Writing/Runnign an example

1) Open iMacrosTest.java

2) Copy the following code to iMacrosTest.java:

Code: Select all

//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;

public class iMacrosTest {

	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();
		}

	}
}
[Edit: changed "URL GOTO=www.iopus.com" to "URL GOTO=http://www.iopus.com]
[Update]Changed TAG command to comply with web page layout.[End of update]

3) You might want to select the full code and have it automatically be indented with "CTRL-i"

4) Menu: Run --> Run...

Image

5) Rightclick Java-Application --> New

Image

6) Under "Classpath" you should find the jawin.jar

Image

7) Under "Common" check both Debug and Run

Image

8) Click Run
this can later be accessed by the Run-Button:

Image

The Java class will now be compiled and started. It will open an iMacros browser window that visits http://www.iopus.com
Last edited by Hannes, Tech Support on Mon Aug 23, 2010 8:39 am, edited 2 times in total.
Reason: Added link to NetBeans tutorial
killer_mpg
Posts: 9
Joined: Wed Mar 12, 2008 12:56 am

Re: Using iMacros with JAVA (via the Jawin package) in Eclipse

Post by killer_mpg » Tue Mar 18, 2008 12:59 am

Does this work with linux?
Hannes, Tech Support

Re: Using iMacros with JAVA (via the Jawin package) in Eclipse

Post by Hannes, Tech Support » Tue Apr 29, 2008 9:46 am

For Firefox, you can use the JavaScript Scripting Interface: http://wiki.imacros.net/iMacros_for_Fir ... _Interface
Hannes, Tech Support

Files

Post by Hannes, Tech Support » Fri May 02, 2008 10:30 am

The attached ZIP contains the full Eclipse workspace folder for the project.
(You may probably need to adjust the paths.)
Attachments
iMacrosScriptingInterface.zip
(81.08 KiB) Downloaded 3729 times
sothy1962
Posts: 0
Joined: Mon Jun 30, 2008 8:13 pm

Re: Using iMacros with JAVA (via the Jawin package) in Eclipse

Post by sothy1962 » Mon Jun 30, 2008 8:21 pm

Silly question, but is the expectation that one builds the jawin.jar file as it was not in the download?
Hannes, Tech Support

Re: Using iMacros with JAVA (via the Jawin package) in Eclipse

Post by Hannes, Tech Support » Tue Jul 01, 2008 6:54 am

If you download the binary 1.0.19 (jawin-1.0.19.zip, you will probably need to scroll down on that page), you will find the "jawin.jar" in "jawin-1.0.19/lib".
talz13
Posts: 8
Joined: Mon Dec 01, 2008 6:58 pm

Re: Using iMacros with JAVA (via the Jawin package) in Eclipse

Post by talz13 » Mon Dec 01, 2008 7:00 pm

Is there any way to use full java scripting under linux? Jawin is only for windows as far as I can see. I found j-interop on google, but don't know if that can take the place of jawin.
User avatar
Tech Support
Posts: 4948
Joined: Tue Sep 20, 2005 7:25 pm
Contact:

Re: Using iMacros with JAVA (via the Jawin package) in Eclipse

Post by Tech Support » Mon Dec 01, 2008 10:17 pm

Currently, the iMacros Scripting Interface works only on Windows OS, however you can use popular "Linux" languages such as Perl, Python, PHP or Ruby to script it on Windows. Of course, iMacros also runs well on a virtual machine that you can host on your Linux server.

We plan to release a native Linux version in 2009. If you are interested in beta-testing such a version please email info AT iopus.com and we will notify you once the first beta is available.

Last but not least, you can already use iMacros for Firefox on Linux and control the browser via the command line interface:
http://wiki.imacros.net/iMacros_for_Fir ... ne_Support
Hannes, Tech Support

Re: Using iMacros with JAVA (via the Jawin package) in Eclipse

Post by Hannes, Tech Support » Mon Apr 27, 2009 6:07 pm

Please cf. the answer above.
srinivas
Posts: 1
Joined: Mon Jul 13, 2009 7:42 am

Re: Using iMacros with JAVA (via the Jawin package) in Eclipse

Post by srinivas » Mon Jul 13, 2009 7:50 am

Hi , I used the same code to test.I follow the same steps what it was mentioned in the above.But it was not working. I got the output as VT_BSTR .
can any one tell me the solution.
Hannes, Tech Support

Re: Using iMacros with JAVA (via the Jawin package) in Eclipse

Post by Hannes, Tech Support » Mon Jul 13, 2009 1:13 pm

richermartyn
Posts: 0
Joined: Tue Sep 08, 2009 11:33 am

Re: Using iMacros with JAVA (via the Jawin package) in Eclipse

Post by richermartyn » Tue Sep 08, 2009 11:38 am

Thank you for providing a information about Eclipse and I have download this url and I have installed in my system I follow such steps which you given over here. It's working Properly.
Hannes, Tech Support

Running from the command line

Post by Hannes, Tech Support » Tue Aug 17, 2010 11:31 am

When run from the command line, both locations of the jawin library/binary (jawin.jar and the folder of jawin.dll) must be given in "classpath" and "java.library.path", respectively.

Given that both, the eclipse project and the jawin folder reside in c:\users\name\eclipse.workspace, here's how the command line calling "DownloadTest.class" looks like:

Code: Select all

C:\Users\name\eclipse.workspace\iMacrosJavaDownloadTest\bin>java -classpath C:\Users\name\eclipse.workspace\iMacrosJavaDownloadTest\bin;C:\Users\name\eclipse.workspace\iMacrosJavaDownloadTest\res\jawin-2.0-alpha1\lib\jawin.jar -Djava.library.path=c:\users\name\eclipse.workspace\jawin-2.0-alpha1\bin DownloadTest
Hannes, Tech Support

Re: Using iMacros with JAVA (via the Jawin package) in Eclip

Post by Hannes, Tech Support » Mon Aug 23, 2010 8:40 am

The Jawin library does not support 64bit. However, there's a replacement called JACOB (http://sourceforge.net/projects/jacob-project/). It's pretty easy to use and the main steps given in the initial post still hold. Just replace any reference to jawin with the appropriate JACOB one. Additionally, I have posted a small HowTo here.
Post Reply