Solved

Controlling another ap with SendKeys

Posted on 2002-05-03
6
203 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
ID: 6989406
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
ID: 6989471
Hi DragonSlayer - thanks for the reply.  How do I do that?

John
0
 
LVL 8

Expert Comment

by:Cesario
ID: 6989496
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 3

Author Comment

by:jdthedj
ID: 6989583
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
ID: 6989623
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
ID: 6990092
Thanks Cesario - I've got it working.

John
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

863 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

26 Experts available now in Live!

Get 1:1 Help Now