views:

671

answers:

4

I want to "view" information displayed by another application and "click" different buttons to automate a process. Have never done this before and would appreciate any advice on where to start and/or links.

+5  A: 

With some SendMessage() you can simulate a user interacting with any program you wish. This is the heart of all "auto click" or Macro programs.

WinSight (Borland\Delphi7\Bin\WS32.EXE) may be very helpful to get stuff ID to use with SendMessage(). You will also have to make use of FindWindow().

Havenard
+3  A: 

The proper way to automate another application on Windows platform is through the use of the UI Automation framework. It supports both .Net and COM APIs with the same level of functionality.

Disclaimer: I have not touched Delphi in years, so I have no idea which one will be easier for you to use.

Note that the UI Automation works on XP and above only; if for some reason you need to automate applications on Win2k or Win9x, you should look at the Windows Active Accessibility APIs.

Franci Penov
+3  A: 

You can use WinDowse (is freeware) for obtaining necessary technical information about any window.

This example show how simulate a click button, using x,y coordinates

Procedure PressButtonXY(handleWnd : HWND;X,Y : Integer);   //X,Y are relative to the client area, you can use ScreenToClient to obtain this.
var
LParam    : Integer;
begin
LParam    := MakeLong(X, Y);
PostMessage(handleWnd, WM_LBUTTONDOWN, MK_LBUTTON, LParam);
PostMessage(handleWnd, WM_LBUTTONUP, MK_LBUTTON, LParam);
end;
RRUZ
+1  A: 

One thing to be aware of is that posting messages across application boundaries will not all ways work on Vista (or windows 7). If an application is launched in another security context, for example running as admin, then the post messages from another application in another security context will be blocked.

skamradt