Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Click a button on another Delphi app

Posted on 2002-06-26
5
Medium Priority
?
314 Views
Last Modified: 2010-08-05
I have one Delphi application that launches another at a specified time. The 2nd app has a 'Start' button that I wish to simulate pressing after the application has loaded. I have seen an example similar to this on EE (but i can't find it) where Outlook was launched with a message and the 'Send' button was pressed after a delay.

Any idea's ?.
Thanks
Paul.
0
Comment
Question by:pr_wainwright
[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
5 Comments
 
LVL 1

Expert Comment

by:VENKAT
ID: 7112617
Sorry, I couldn't understand what u mean. Can u please brief what u need exactly? Thank you.
0
 
LVL 1

Author Comment

by:pr_wainwright
ID: 7112749
Sorry,
      Two Delphi applications running (A & B). Delphi application 'A' wants to 'Press' a button on Delphi application 'B' main form (execute button1.click; handler).

Hope this is a bit clearer.
Paul.
0
 
LVL 11

Expert Comment

by:robert_marquardt
ID: 7112874
Send the proper WM_KEYDOWN/WM_KEYUP messages for the button's shortcut. Directly executing code from another app is impossible.
0
 
LVL 2

Accepted Solution

by:
Tasomia earned 400 total points
ID: 7112992
Hi

Try this code:

function EnumChildProc(Wnd: hWnd; SL: TStrings): BOOL; stdcall;
var
  szFull: array[0..MAX_PATH] of Char; //Buffer for window caption
begin
  Result := Wnd <> 0;
  if Result then  
  begin
    GetWindowText(Wnd, szFull, SizeOf(szFull)); // put window text in buffer
    if (Pos(SL[0], StrPas(szFull)) > 0) // Test for text
      and (SL.IndexOfObject(TObject(Wnd)) < 0) // Test for duplicate handles
      then SL.AddObject(StrPas(szFull), TObject(Wnd)); // Add item to list
    EnumChildWindows(Wnd, @EnumChildProc, Longint(SL)); //Recurse into child windows
  end;
end;

function ClickButton(ParentWindow: Hwnd; ButtonCaption: string): Boolean;
var
  SL: TStringList;
  H:  hWnd;
begin
  SL := TStringList.Create;
  try
    SL.AddObject(ButtonCaption, nil); // First item in list is text to find
    EnumChildWindows(ParentWindow, @EnumChildProc, Longint(SL));
    H := 0;
    case SL.Count of
      1: ShowMessage('Window text not found.');
      2: H := hWnd(SL.Objects[1]);
      else  
        ShowMessage('Ambiguous text detected.');
    end;
  finally
    SL.Free;
  end;
  Result := H <> 0;
  if Result then PostMessage(H, BM_CLICK, 0, 0);
end;

tas
0
 
LVL 1

Author Comment

by:pr_wainwright
ID: 7113106
Tasomia,
        Just what i was looking for.

Thanks
Paul.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

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…
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, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

610 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