tags:

views:

458

answers:

2

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

+1  A: 

It seems that this is encapsulated inside the jna project from java.net projects:

https://jna.dev.java.net

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;
REA_ANDREW
+1  A: 

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.

DMKing
I wonder if WoW's fancy bot detection setup can identify that?
basszero
I dunno, it never did when I used it but that has been a couple of years. I wouldn't think automating your login would be bad but that's just my opinion.
DMKing