In Delphi, I'm trying to programattically send text to the Find window in an Edge Browser. After using WinSpector Spy, I see that the Find Window comes up as a "Chrome_WidgetWin_1" object. I would like to know how to get the handle for this object so I can use PostMessage()
to send it text directly.
I am able to get the Edge Browser object handle with the following code:
var hchild := GetWindow(MyBrowserGd.EdgeBrowser.Handle, GW_CHILD);
ManulifeGd.Edit3.Text := IntToHex(hchild);
I am able to send PostMessage()
to the browser without issue.
However, I'm uncertain how to get the handle for the Find window.
I've tried a variety of things, such as using GW_HANDLENEXT
, GW_ENABLEDPOPUP
in the GetWindow()
function, but I'm just not certain what the Edge Browser allows for with regards to these objects.
In Delphi, I'm trying to programattically send text to the Find window in an Edge Browser. After using WinSpector Spy, I see that the Find Window comes up as a "Chrome_WidgetWin_1" object. I would like to know how to get the handle for this object so I can use PostMessage()
to send it text directly.
I am able to get the Edge Browser object handle with the following code:
var hchild := GetWindow(MyBrowserGd.EdgeBrowser.Handle, GW_CHILD);
ManulifeGd.Edit3.Text := IntToHex(hchild);
I am able to send PostMessage()
to the browser without issue.
However, I'm uncertain how to get the handle for the Find window.
I've tried a variety of things, such as using GW_HANDLENEXT
, GW_ENABLEDPOPUP
in the GetWindow()
function, but I'm just not certain what the Edge Browser allows for with regards to these objects.
1 Answer
Reset to default 0If the element (the Find window in your example) is identifiable to Javascript (e.g. has a name attribute), then you can use Javascript from Delphi to access and modify it.
For example, let's say you have navigated to the current Embarcadero Quality Portal web page (just using it as an example of a web page with an input field):
EdgeBrowser.Navigate('https://embt.atlassian.net/servicedesk/customer/user/login');
Then, after inspecting the page's source and finding out the details about its input field for Email address:
<input id="user-email" name="user-email" aria-describedby="field-error" type="text"
autocomplete="email" data-ds--text-field--input="true" class="css-mfjdp3" value="">
Then you can programmatically enter an e-mail into the input box, which has name="user-email"
, with this:
EdgeBrowser.ExecuteScript(
'let email_input = document.getElementsByName("user-email"); ' +
'email_input[0].focus(); ' +
'document.execCommand(''insertText'', false, ''[email protected]'');');
GetDlgItem()
orFindWindowEx()
to locate a specific child window in a parent window – Remy Lebeau Commented Feb 5 at 16:13