Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with screen scraping/key sending

Status
Not open for further replies.

TheBugSlayer

Programmer
Sep 22, 2002
887
US
Hello wonderful people.

I need to write an application that communicate with another one somehow. There is one application that displays an image at the top and a connection to mainframe at the bottom. I cannot modify this program but I need to be able to get data from the top and build a string that I will try to paste at the bottom. The aim is to minimize keyers keystrokes and increase throughput.

I have heard of AttachMate. Any other tool out there, how to use it, documentation, samples, etc.

Thanks for your help.

PS: I have never done this before.
 
Let me ask the question in a different way. How do I read from my program information displayed in another application's form? I need to look for a caption and read the data next to it, is that possible at all?
 
Hi,

it is possible but you got to have a program like spy++ or winsight to ease the work

to find the handle of a specific control on a window in an application you must first get the applications main window like this :

// try to find application window through it's caption
hwnd_TOP:=Findwindow(PChar(Appname),nil); // look for APP
// if the window has no caption, you got to use it's classname (can be found with spy++)
hwnd_TOP:=Findwindow(nil,PChar(Classname)); // look for APP

once you got the main handle, you can use it to look for it's child windows :

hwnd_MDI:=FindWindowEx(hwnd_TOP,0,PChar(Classname),nil); // get mdiclient window area

once you found the window you want (the one with the control you want to monitor)you must search for this control :

// look for the first edit box (to see the order of the controls, use spy++
hwnd_CONTROL:=FindWindowEx(hwnd_TOP,hwnd_MDI,pchar('Edit'),nil);

now that we got the control handle , you can use specific control window messages to do something with it :

// set text of first edit box to 'hello there!'
wtext:='hello there!';
SendMessage(hwnd_CONTROL,WM_SETTEXT,0,integer(pchar(wtext)))

to obtain text you can use the WM_GETTEXT message.

to obtain more information about those win messages, take a look at the win32 SDK manual in Delphi or just go the microsoft MSDN site :

hope this can help you a bit :))

Cheers






you must
you must find the class name of the wind


--------------------------------------
What You See Is What You Get
 
In addition to whosrdaddy's post.

Here's how to get all the identifiers for all the controls on the SaveDialog so that you add one Memo to a form and then add this to the OnShow event of the form (of course you can use a button also):

Code:
function EnumChildProc(Ctrl: hWnd; List: TStrings): Bool; stdcall;
var
  Buf : array [0..80] of char;
  Id  : integer;
  Caption : array [0..80] of char;
begin
  Result := True;
  getClassName(Ctrl, buf, 80);
  Id := GetDlgCtrlId(Ctrl);
  GetWindowText(Ctrl, Caption, 80);
  List.Add(Format('Class: <%s>, Id: <%d>, Caption: <%s>', [Buf, Id, Caption]));
end;

Example of usage:

How to get control id's from a savedialog from the same application you're coding:

EnumChildWindows(Windows.GetParent(SaveDialog1.Handle), @EnumChildProc, LongInt(Memo1.Lines));

You can use this (propably even without modifications) with whosrdaddy's ideas.
 
Thank you guys. I will try and let you know.
So this works only for Windows, right? If that's the case, this resolves the first part of the problem. The other part is the bottom screen of the application, which is an AttachMate connection to a mainframe (I hope I am speaking the proper language), you know, one of those black MS-DOS-like screens...Would it be possible to put a text there in a specific location?



PS:
This guy on has a few freeware. Among them Handler; it is a small program that gives you the handle, caption, class name and control ID of the object and its parents. A great tool!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top