Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8872951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:20:39+00:00 2026-06-14T18:20:39+00:00

I got the following code from here and have changed it a little and

  • 0

I got the following code from here and have changed it a little and I have changed the original question a little also.

The timer interval is set to 5000.
After the following 3 events occur the ‘Events OnTimer’ procedure will start to work.

  • 1.WebBrowser1.Navigate(‘Any webpage’);
  • 2.wait for it to load
  • 3.programmatically press a download file button

The problem now is I can’t find the ‘Edit'(Class Name) handle that belongs to(or is the child of) the ‘Save as’ dialog box. The handle for the ‘Edit’ comes to ‘0’ in the code below, but if I use my mouse pointer and the following code:

HND:= WindowFromPoint(PNT);
Label1.Caption:= IntToStr(HND);

the handle gives a result. Once I have the handle, I can use:

SetWindowText(EditHandle, 'test text'); 

to change the text in ‘Edit'(Class Name).

procedure TForm1.Timer1Timer(Sender: TObject);
Var
WHandle : HWND ;
ParentHandle : DWORD ;
P : Array[0..256] Of Char ;
ProcessIdActif : DWORD ;

begin
ProcessIdActif := 0 ;
GetWindowThreadProcessId (handle,@ProcessIdActif);
WHandle := FindWindow( Nil, Nil);
While (WHandle <> 0) Do
  begin 
    P[0] := #0;
    GetWindowText(WHandle, P, 255);
    if P[0] <> #0 then
      begin
        GetWindowThreadProcessId (WHandle,@ParentHandle);
        if ProcessIdActif = ParentHandle then
          begin
          if CompareText(p,'File Download') = 0 then
            begin
              ButtonHandle := FindWindowEx(WHandle, 0, 'Button', '&Save');
              if (ButtonHandle > 0) then
               PostMessage(ButtonHandle, BM_CLICK, 0, 0);       
            end
          else if CompareText(p,'Save As') = 0 then
            begin
              EditHandle := FindWindowEx(WHandle, 0, 'Edit',NIL);
              if (EditHandle > 0) then
                SetWindowText(EditHandle, 'test text');
            end;                
          end;
      end;
      WHandle := GetWindow(WHandle, GW_HWNDNEXT);
  end;
end;

I’ve been trying to understand everything here but I’m missing something.

I’m able to press any windows dialog button by moving the mouse and pressing the mouse programatically, but I’d like to figure out how to press these buttons in a cleaner way.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T18:20:41+00:00Added an answer on June 14, 2026 at 6:20 pm

    Disclaimer: the below code is not meant to be used in any way, it won’t work correctly if the environment is different anyway (W7 here).

    Anyway, put the below in your timer handler and try to workout the differences (if it works hopefully..) with the code in the question:

    var
      WHandle, ButtonHandle, EditHandle: HWND;
    begin
      WHandle := FindWindow('#32770', 'File Download');
      if WHandle <> 0 then begin
        SetForegroundWindow(WHandle);
        ButtonHandle := GetDlgItem(WHandle, $114B);
        if ButtonHandle <> 0 then begin  // click the button
          // the dialog/button is kind of deaf.. 
          while IsWindowEnabled(WHandle) do begin
            SendMessage(ButtonHandle, BM_CLICK, 0, 0);
            Sleep(100);
          end;
          WHandle := 0;
          while WHandle = 0 do begin     // wait for the save as dialog
            WHandle := FindWindow('#32770', 'Save As');
            Sleep(100);
          end;
          while not IsWindowVisible(WHandle) do
            Sleep(100);
          // get through the edit handle
          WHandle := FindWindowEx(WHandle, 0, 'DUIViewWndClassName', nil);
          EditHandle := GetWindow(GetWindow(GetWindow(GetWindow
                        (WHandle, GW_CHILD), GW_CHILD), GW_CHILD), GW_CHILD);
          SetWindowText(EditHandle, 'test text');
        end;
      end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got the following code from another question on SO to track the changing
I am following up from this question here The problem I have is that
I got following code from net and it looks everything is proper but i'm
I got the following code from the designer: <table class=items> <thead> <tr> <th id=name>name</th>
Ive got the following code which I hacked together from website examples. It works
I've got the following code that's taking photos from a flickr feed via JSON
I've got the following code to output a list of items from amazon, but
I need to return server time from a webservice. I've got the following code:
in the following piece of code I got from a book. The NSString *pPath
I have got the following code: - (void)tableView:(UITableView *)tableView commitEditingStyle: (UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.