Ask a Question

How do I control "Notepad" that my program opens.

1222tmiller
Occasional Contributor

How do I control "Notepad" that my program opens.

If you have a problem connecting to our system, we automatically do an IP Trace and show it in Notepad.  For the test script to complete, I need to close it.  (using Delphi Script).



How do I get a handle to a program that is already running?

How do I do a Wait for it to open (see my example below)?

How do I close the program gracefully?



This is what I do in other areas for a wait



  while (MyApp.FrmErrorDlg.Exists = false)  do

        aqUtils.Delay(1000); // 1 sec delay



hopefully can do something like



  while (Sys.Process("Notepad").Exists = false)  do

        aqUtils.Delay(1000); // 1 sec delay
-
Tom Miller
PIDI
Software Development Manager
1 REPLY 1


Hello Tom,





I recommend that you use the Sys.WaitProcess method to wait for a process. The following script waits for the Notepad process and closes it without saving the changes.







procedure Test1;

  var notepad : OleVariant;

  var wndNotepad : OleVariant;

begin

  notepad := Sys.WaitProcess('Notepad', 10000);

  if( notepad.Exists) then 

  begin

     wndNotepad := notepad.Window('Notepad');

     wndNotepad.Close();

     if (notepad.WaitWindow('#32770', 'Notepad').Exists) then

       notepad.WaitWindow('#32770', 'Notepad').Keys('n');

  end;

end;

--
Dmitry Nikolaev

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
cancel
Showing results for 
Search instead for 
Did you mean: