Solved

Controlling another ap with SendKeys

Posted on 2002-05-03
6
209 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
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…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

728 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