Home > Back-end >  Using DELPHI control download pop-up window and click save to why not
Using DELPHI control download pop-up window and click save to why not

Time:10-04

After I use DELPHI to file download in the pop-up window directly simulate click save button, but is not successful, can only be parked the focus on the save button, after the action does not perform, please expert help, the code is as follows:

Procedure TForm1. Button1Click (Sender: TObject);
Var
H, hc: HWND;
I: integer;
The begin
H:=findwindow (nil, 'file download);
If H & gt; 0 then
The begin
//FindWindowEx (h, 0, 'Button', 'save (& amp; S) ')
Hc:=FindWindowEx (h, 0, 'Button', 'save (& amp; S) ");
If hc> 0 then
The begin
//Windows. SetForegroundWindow (h);
SendMessage (hc, WM_LBUTTONDOWN, 0, 0);
//Sleep (20);
SendMessage (hc, WM_LBUTTONUP, 0, 0);
//Sleep (20);
//SendMessage (hc, BM_CLICK, 0, 0);
//Sleep (20);
PostMessage (hc, BM_CLICK, 0, 0);

//PostMessage (hc, WM_KEYDOWN, VK_RETURN, 0); SendMessage (hc, WM_LBUTTONDOWN, 0, 0);
//SendMessage (hc, VK_RETURN, 0, 0);
//keybd_event (KEYEVENTF_KEYUP VK_RETURN, 0, 0);
//PostMessage (hc, VK_RETURN, 13, 0).
{SendMessage (hc, WM_LBUTTONDOWN MK_LBUTTON, MAKELPARAM (100, 200));

SendMessage (WM_COMMAND, ID_FILE_SAVE_AS, 0);
Keybd_event (VK_MENU, 0, 0, 0).
Keybd_event (VK_RETURN, 0, 0, 0).

Keybd_event (KEYEVENTF_KEYUP VK_RETURN, 0, 0);
Keybd_event (KEYEVENTF_KEYUP VK_MENU, 0, 0);
SendMessage (hc, WM_LBUTTONUP MK_LBUTTON, MAKELPARAM (100200));
}

End
end;
end;

CodePudding user response:

Set the download window into the current window

CodePudding user response:

Is the IE download box? If it is that is likely to COM

CodePudding user response:

This is caused by code running mechanism are not synchronized, especially the unique writing file (download), it is recommended to use threads,

CodePudding user response:

refer to the second floor mytion response:
is IE download box? If it is that is likely to COM on


Yes,



Run my program can only be parked the focus on the save button, just don't perform the following analog keyboard key, please advice!

CodePudding user response:

reference lyhoo163 reply: 3/f
this is caused by code running mechanism is not synchronized, especially the unique writing file (download), it is recommended to use threads,



Please comment should be how to use a thread to perform?

CodePudding user response:

Look ace, he prowled the their top

CodePudding user response:

See child window handle to find the right no, use spy++ picture and then compare the window handle hc

CodePudding user response:

Simulate the enter events:
Keybd_event (VK_RETURN, MapVirtualKey (VK_RETURN, 0), 0, 0).
Keybd_event (VK_RETURN, MapVirtualKey (VK_RETURN, 0), KEYEVENTF_KEYUP, 0).

CodePudding user response:

refer to the eighth floor simonhehe response:
simulation enter events:
Keybd_event (VK_RETURN, MapVirtualKey (VK_RETURN, 0), 0, 0).
Keybd_event (VK_RETURN, MapVirtualKey (VK_RETURN, 0), KEYEVENTF_KEYUP, 0).


These are tried is not, I don't know if I call the main program must hide first or what problem, because these in my another program control PDF reader can run normally, but can't control the "download" this pop-up window

CodePudding user response:

Try to simulate the shortcut key

CodePudding user response:

references to the tenth floor LGHT response:
try to simulate the shortcut keys


Thank you very much! I also simulates the CTRL + S also does not perform, I don't know why? Just can positioning to "save" button, but does not perform any buttons

CodePudding user response:

11 references szchenzb response:
Quote: reference to the tenth floor LGHT response:

Try to simulate the shortcut keys


Thank you very much! I also simulates the CTRL + S also does not perform, I don't know why? Just can positioning to "save" button, but does not perform any keys


How is Ctrl + S, is Alt + S
  • Related