Reputation: 538
Basically I am attempting to control a win32 app (press a button, add stuff to a text field) etc from a java app.
Whats the best method of attempting this (i.e are there any toolkits, DDE?) or will I have to attempt to do some sort of FindWindowEx, then send a WM_LBUTTONDOWN or something?
Cheers
Upvotes: 1
Views: 1699
Reputation: 10764
It seems that this is encapsulated inside the jna project from java.net projects:
Well it is one possibility anyway.
In one example it shows a few imports which look like they may be of use to you:
import com.sun.jna.examples.win32.GDI32;
import com.sun.jna.examples.win32.User32;
import com.sun.jna.examples.win32.GDI32.BITMAPINFO;
import com.sun.jna.examples.win32.User32.BLENDFUNCTION;
import com.sun.jna.examples.win32.User32.POINT;
import com.sun.jna.examples.win32.User32.SIZE;
import com.sun.jna.examples.win32.W32API.HANDLE;
import com.sun.jna.examples.win32.W32API.HBITMAP;
import com.sun.jna.examples.win32.W32API.HDC;
import com.sun.jna.examples.win32.W32API.HRGN;
import com.sun.jna.examples.win32.W32API.HWND;
Upvotes: 1
Reputation: 1715
Use the Java Robot. Class is java.awt.robot. It works great for controlling other applications. See here:
http://java.sun.com/javase/6/docs/api/java/awt/Robot.html
I actually used this to automate logins to World of Warcraft back when I played a lot. The server I played on almost always had a login queue that took about 30 minutes to get through. So I had the Windows scheduler kick off my Robot program about 4:45pm. It would send a shortcut combination to Windows to launch WoW. Then it would pause for a time then send keystrokes to enter my password and log me in. By the time I got home from work I would be ready to play without having to wait in the queue.
Upvotes: 1