Solved

Controlling another ap with SendKeys

Posted on 2002-05-03
6
206 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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

809 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