Solved

Controlling another ap with SendKeys

Posted on 2002-05-03
6
202 Views
Last Modified: 2008-03-03
Hi

I am trying to control Adobe Acrobat from Delphi to automate a lengthy process.  I am sending keystrokes to Acrobat to control it. Everything works fine until there is an error.  

I have been using FindWindowEX to find out when a progress dialog window closes, thus signifying that it has finished its process, but if there is an error the progress dialog does not come up - just an error messagebox.  Both the progress dialog and the error messagebox have the same window title text.

Is there any way to tell whether Acrobat has thrown an error, or is just processing the files?  

If there is an error the error messagebox eventually closes because of a #13 keystroke sent to Acrobat in its normal stream of keystrokes, but the rest of the processing on the file does not take place, and Acrobat eventually runs out of resources because the individual files which produce errors are not closing when they should.

John
0
Comment
Question by:jdthedj
  • 3
  • 2
6 Comments
 
LVL 14

Expert Comment

by:DragonSlayer
Comment Utility
perhaps you can also check the caption of the static text (i.e. the content of the dialog box)?
0
 
LVL 3

Author Comment

by:jdthedj
Comment Utility
Hi DragonSlayer - thanks for the reply.  How do I do that?

John
0
 
LVL 8

Expert Comment

by:Cesario
Comment Utility
With EnumChildWindows.
you can check the name of the first Control in your dialogbox

somthing like:

Function EnumProc ( H:THandle;Par:Word):Boolean; StdCall;
VAR
  ca:Array[1..250] of char;
Begin
  GetClassName(H,@Ca,SizeOf(ca));
  showMessage(ca);                   // this is the name of the control
  result := False;
End;

Procedure Tform1.xxxx;
Begin
   // get the handle of the dialogbox

   enumChildWindows ( TheDialogBox Handle,@EnumProc,0);
End;

Best Regards

Cesario

0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 3

Author Comment

by:jdthedj
Comment Utility
Hi Cesario - thanks for the code.  

Just one problem - the EnumChildWindows call will not accept the 0 parameter at the end - it wants a variable.  What do I need to use for that?

John
0
 
LVL 8

Accepted Solution

by:
Cesario earned 50 total points
Comment Utility
If have no Problems with this Function.

EnumChildWindows need three Parameters:
  1. The Handle of your Dialog
  2. EnumProc Function
  3. is an Integer

for more Information look into your Online Help


Function EnumProc ( H:THandle;Par:Word):Boolean; StdCall;
VAR
 ca:Array[1..250] of char;
Begin
 GetClassName(H,@Ca,SizeOf(ca));
 showMessage(ca);                   // this is the name of the control
 result := False;
End;

Procedure Tform1.Button1Click(Sender:TObject);
VAR
  hDlg : THandle;
Begin
  hDlg := FindWindow (....................);
  IF hDlg>0 Then
  Begin
    enumChildWindows ( hdlg,@EnumProc,0);
  End;
End;
0
 
LVL 3

Author Comment

by:jdthedj
Comment Utility
Thanks Cesario - I've got it working.

John
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This video discusses moving either the default database or any database to a new volume.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now