I have worked with the clipboard in Delphi so no help there. I have a website that has 10 text area boxes, and I need to paste some text from my Delphi VCL app into these textareas on the webpage.
Here is one of the text area on the page:
<textarea name="txtGoalTransaction275746_0" rows="3" cols="20"
id="txtGoalTransaction275746_0"
onkeyup="Count(this, 5000)" onchange="Count(this, 5000)"
style="width:400px;"></textarea>
I can not use TWebbrowser as the website does not work correctly in TWebbrowser.
I am looking for a method to paste from clipboard into the textarea from my Delphi VCL app.
Any help is appreciated.
I can log into the site fine with
JSCode := 'document.getElementById("username").value = "myusername";' +
'document.getElementById("pwd").value = "myPaseword";' +
'document.forms[0].submit();';
So I know I am working with edgebrowser ok.
I am trying
procedure TForm1.Button1Click(Sender: TObject);
begin
EdgeBrowser1.ExecuteScript(
'document.getElementById("txtGoalTransaction271900_0").value ="Test String"');
end;
But nothing gets put in the textarea.
I wonder if there is a way to enumerate all the elements that are on the webpage that is displayed in tedgebrowser.
If you have Delphi 10.4.2 or higher, you can use the
TEdgeBrowsercomponent.Once the web page is loaded into the browser, you can use the TEdgeBrowser's
ExecuteScriptmethod. It runs arbitrary Javascript. You can thus use JavaScript from Delphi to set the value of the textarea, like this:To answer your specific question, the contents of the clipboard would be used like this:
For TEdgeBrowser to work, you need to have Microsoft's WebView2 Run-Time installed, and WebView2Loader.dll must be present in your EXE file's directory.